We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content
Schedule Cloudflare Pages Builds with a robot arm holding a clock and a cloudflare logo
Home Blog Cloudflare

Schedule Cloudflare Pages Builds

Schedule your Cloudflare Pages builds to run at specific times. No external services needed.

Published on:
Clock Time to complete: 10 minutes

Static sites often need regular rebuilds. You might have content scheduled for future dates or time-sensitive information that needs to appear automatically. For blogs with scheduled posts, daily builds ensure new content appears right on time without manual intervention.

With Cloudflare Pages, you can set up automated builds using their built-in tools - no external services needed.

  • The free tier includes 500 builds per month
  • This is plenty for daily builds (30-31 per month) with room for manual deploys
  • Scheduled builds are perfect for blogs with future-dated content
  1. Open your Cloudflare dashboard and go to Workers & Pages
  2. Select the Pages project you want to schedule builds for Cloudflare Pages Select Project
  3. Navigate to Settings and find the Deploy Hooks section Cloudflare Pages Settings Deploy Hooks
  4. Click the plus icon to create a new hook
  5. Name your hook (e.g., “scheduled-build”) and select the branch you want to deploy Cloudflare Pages Name Deploy Hook
  6. Copy the generated URL - you’ll need this for the next step

This URL triggers a build when it receives a POST request. Now we need to schedule when to call it.

Limited Time Launch Sale

Want to build your own scheduled blog? Our AstroJS starter template includes everything you need to create a professional, SEO-optimized site with scheduled posts.

GET 60% OFF!

Cloudflare Workers provide serverless functions that can run on a schedule:

  1. Go back to the Workers & Pages section in your Cloudflare dashboard
  2. Click “Create application” Cloudflare Pages Create Worker
  3. Select “Workers” and click “Hello World” starter Cloudflare Hello World Worker
  4. Name your worker (e.g., “scheduled-build-worker”) Cloudflare Name Worker
  5. Click “Deploy” and then “Continue to project” Cloudflare Worker Continue
  6. In the worker editor, replace the default code with this:
export default {
async scheduled(controller, env, ctx) {
ctx.waitUntil(
async () =>
await fetch('<your-deploy-hook-url>', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
})
);
},
async fetch(request) {
return new Response('This worker is for scheduled tasks only.', { status: 404 });
},
};

For more information on Cloudflare Workers, see the Cloudflare Workers scheduled handler docs.

Cloudflare Worker Edit Code

Replace <your-deploy-hook-url> with the deploy hook URL you copied earlier. This code tells the worker to make a POST request to your deploy hook URL whenever the scheduled function runs.

  1. Click “Deploy” to save your worker
  1. Go to the “Settings” tab of your worker

  2. Scroll down to “Triggers” and click “Add Trigger”

    Cloudflare Worker Trigger Event
  3. Select “Cron Trigger”

    Cloudflare Worker Cron Trigger
  4. Choose your schedule:

    • For daily builds, use a cron expression like 0 5 * * * (runs at 5:00 AM UTC daily)
    • For weekly builds, try 0 5 * * MON (runs at 5:00 AM UTC every Monday)
    Cloudflare Worker Schedule Cron Trigger
  5. Click “Add” to save your schedule

For a blog with scheduled posts, a daily build at early morning (like 5:00 AM) works well. This ensures new content appears at the start of each day.

Cron expressions might look confusing at first, but they’re quite simple once you understand the format:

┌─────────── minute (0 - 59)
│ ┌───────── hour (0 - 23)
│ │ ┌─────── day of the month (1 - 31)
│ │ │ ┌───── month (1 - 12)
│ │ │ │ ┌─── day of the week (0 - 6) (Sunday to Saturday)
│ │ │ │ │
* * * * *

Common examples:

  • 0 0 * * * - Every day at midnight
  • 0 */12 * * * - Every 12 hours
  • 0 9 * * 1-5 - Every weekday at 9:00 AM
  1. Check the “Deployments” tab in your Cloudflare Pages project to see successful builds
  2. Monitor your monthly build count to stay within the free tier limits
  3. Check that new content is appearing as expected on your site

If you need more frequent builds, consider:

  • Scheduling only on specific days
  • Using conditional builds that check if new content exists
  • Upgrading your Cloudflare plan for additional builds
  • Setting up notifications for failed builds
Cloudflare Deployment Notifications with checkboxes and a notification bell

Cloudflare Pages Deployment Notifications

Set up instant alerts when your Cloudflare Pages site deploys or encounters build failures

  1. Verify your deploy hook URL is correct in the worker code
  2. Check that your worker is deployed successfully
  3. Ensure the cron trigger is properly configured
  4. Look at the worker’s execution logs for any errors
  5. Confirm your Cloudflare Pages project is still connected to the correct repository

With this setup, your Cloudflare Pages site will automatically rebuild on schedule, publishing any time-sensitive content exactly when needed - no manual intervention required. The combination of Cloudflare Pages and Workers provides a powerful, free solution for automating your static site deployment process, all within the Cloudflare ecosystem.

For More tips on optimizing your Clouflare pages site, check out our other articles below.

Related Articles

Read more Cloudflare articles
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes