To schedule posts in Astro, give each post a future pubDate, filter out entries whose date is still ahead of the build time with getCollection('blog', ({ data }) => data.pubDate <= new Date()), and rebuild the site on a schedule. A static Astro site only changes when it is built, so the schedule is a cron job that calls your host’s deploy hook, typically once a day.
Key Takeaways
- A scheduled post is a normal post with a future
pubDateand a date filter.- The filter runs at build time, so the post appears at the first build after its date.
- Use a GitHub Actions cron or your host’s scheduler to trigger daily builds.
- Times are compared in UTC unless your dates include an offset.
- Combine the date filter with your draft filter in one helper.
Filter future posts
Put the rule in the helper every page uses:
// src/lib/posts.ts
import { getCollection } from 'astro:content';
export async function getPosts() {
const now = new Date();
const posts = await getCollection('blog', ({ data }) => {
if (data.draft) return false;
return import.meta.env.PROD ? data.pubDate <= now : true;
});
return posts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
}
In dev every post shows, so you can preview scheduled ones; in production builds, posts dated later than the build are skipped. Their pages are not generated, so they stay out of the index, RSS and sitemap until the build that includes them. If you have not added drafts yet, see draft posts in Astro.
Your schema needs a real date for the comparison to work:
// src/content.config.ts (excerpt)
pubDate: z.coerce.date(),
Mind the time zone
pubDate: 2026-11-20 becomes midnight UTC on November 20. If you want a post live at 9:00 in New York, write the time and offset:
---
title: "Winter opening hours"
pubDate: 2026-11-20T09:00:00-05:00
---
The post still only appears when a build runs after that moment, so pick a build time shortly after your usual publish time.
Rebuild on a schedule
Most static hosts give you a deploy hook: a secret URL that starts a new build when it receives a POST. Netlify calls them build hooks, Cloudflare Pages calls them deploy hooks, and Vercel calls them deploy hooks too. Create one in your project settings and store it as a GitHub repository secret named DEPLOY_HOOK_URL. Then add a scheduled workflow:
# .github/workflows/scheduled-build.yml
name: Scheduled build
on:
schedule:
- cron: '15 14 * * *' # 14:15 UTC every day
workflow_dispatch:
jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Trigger deploy hook
run: curl -fsS -X POST "${{ secrets.DEPLOY_HOOK_URL }}"
GitHub Actions cron schedules use UTC and can start a few minutes late at busy times, so do not rely on them for to-the-minute launches. workflow_dispatch adds a manual “Run workflow” button for testing. If you already build and deploy from Actions, add the schedule trigger to that workflow instead of calling a hook; our GitHub Actions workflows guide has full deploy examples.
Show “scheduled” in dev
A small label keeps you from confusing scheduled posts with live ones while writing:
---
// src/components/PostMeta.astro
interface Props { pubDate: Date }
const { pubDate } = Astro.props;
const scheduled = pubDate > new Date();
---
<p>
<time datetime={pubDate.toISOString()}>
{pubDate.toLocaleDateString('en-US', { dateStyle: 'long' })}
</time>
{scheduled && <span class="badge">Scheduled</span>}
</p>
In production the badge never renders, because future posts are not built.
When you need exact timing
If a post must go live at a precise minute, or you publish many times a day, a static rebuild schedule is the wrong tool. Render the blog routes on demand with an adapter and export const prerender = false, so the date check runs on every request, and cache the responses. Our guide to which Astro rendering mode to use covers the trade-off. For most blogs, a daily build is simpler and free.
The deploy docs list where each host keeps its hook settings, and the Blog & Editorial themes are a starting point if you want the blog pages already built.
FAQ
Can Astro schedule blog posts?
Yes, with a date filter and scheduled rebuilds. Astro skips posts dated in the future at build time, and a daily cron build publishes them once their date has passed.
Why didn’t my scheduled Astro post go live?
No build has run since its pubDate, or the date was parsed as UTC midnight later than you expected. Trigger a build manually and check the date in the frontmatter includes the right offset.
Do scheduled posts appear in the Astro RSS feed early?
Not if the RSS endpoint uses the same filtered helper as your pages. If it calls getCollection() directly, it will include them, so route it through the helper.
How often should a scheduled Astro site rebuild?
Once a day suits most blogs. Rebuild more often only if you publish at specific times, and keep an eye on your host’s monthly build limits.