
Static site generators like Hugo do not have a built-in mechanism to automatically publish content–such as blog posts–at a specific time. If you want a post to go live at a certain hour, you need to rebuild and redeploy your site at that moment. This means you have to trigger the build process yourself, which can be inconvenient or easy to forget.
Automated deployments are a key part of modern web development. For static sites or JAMstack projects hosted on Cloudflare Pages , it can be useful to trigger builds on a schedule–even if there are no code changes. This ensures that dynamic content fetched from APIs or other sources stays up to date.
Why Scheduled Builds?
By default, Cloudflare Pages only rebuilds your site when changes are pushed to the repository. But what if your site displays content that updates regularly without code changes? For example, a blog that pulls in external data (RSS feeds, weather, or API content). Scheduled builds help keep your site fresh by rebuilding it automatically at set intervals.
Publishing Dates in Hugo: Frontmatter vs. Filename
Traditionally, Hugo required you to specify the publication date and time for a post using the date property in the frontmatter of your Markdown file. This was the only way to control when a post would be published.
However, since my GitHub issue (Support yyyy-MM-dd-HH-mm-ss in filenames ) and with the release of Hugo version 0.148.0, there is now a new option: you can specify the publication date and even the time directly in the filename of your Markdown file, or in the name of the parent folder. This makes scheduling and managing post publication much more flexible and transparent, especially when combined with scheduled builds.
For example, a file named 2025-07-14_08-00-00_my-post.md or a folder named 2025-07-14_08-00-00_my-post/ will be recognized by Hugo and used to determine the publish date and time, without needing to set it in the frontmatter.
Generate the Build Trigger URL in Cloudflare Pages
To automate builds via GitHub Actions, you need a special build trigger URL from Cloudflare Pages . Here’s how to generate it:
- Go to your Cloudflare Pages project dashboard.
- Click on Settings > Builds & Deployments.
- Scroll down to the Build hooks section.
- Click Add build hook and give it a name (e.g., “GitHub Scheduled Build”).
- Select the branch you want to trigger builds for (usually
mainormaster). - Click Save. Cloudflare will generate a unique URL for you.
- Copy this URL and add it as a secret in your GitHub repository (e.g.,
CLOUDFLARE_BUILD_TRIGGER_URL).
This URL can now be used in your GitHub Actions workflow to trigger builds securely and automatically.
Implementation with GitHub Actions
You can set up a GitHub Actions workflow to trigger a build at specific times. Here’s an example workflow:
1name: Cloudflare Scheduled Build
2
3on:
4 schedule:
5 # Runs every 8 hours (at 00:01, 08:01, and 16:01 UTC)
6 - cron: '1 */8 * * *'
7 workflow_dispatch: # Allows manual triggering
8
9jobs:
10 call-url:
11 runs-on: ubuntu-latest
12 steps:
13 - name: Call Cloudflare Build Trigger URL
14 run: |
15 if [ -z "${{ secrets.CLOUDFLARE_BUILD_TRIGGER_URL }}" ]; then
16 echo "❌ TARGET_URL secret is not set"
17 exit 1
18 fi
19 echo "🔄 Calling URL from secrets..."
20 response=$(curl -s -o /dev/null -w "%{http_code}" -X POST "${{ secrets.CLOUDFLARE_BUILD_TRIGGER_URL }}")
21 if [ $response -eq 200 ]; then
22 echo "✅ URL call successful (HTTP $response)"
23 else
24 echo "⚠️ URL call returned HTTP $response"
25 fi
26 echo "📅 Called at: $(date -u)"
27 env:
28 TARGET_URL: ${{ secrets.CLOUDFLARE_BUILD_TRIGGER_URL }}
29 - name: Log execution
30 run: |
31 echo "🕐 Scheduled execution completed at $(date -u)"
What does this do?
- The workflow runs every 8 hours automatically. In my case I want to deploy on e.g. 08:00 because usually my blog posts go live on 0800 or 1600.
- It uses a secret build trigger URL (
CLOUDFLARE_BUILD_TRIGGER_URL) provided by Cloudflare Pages to send a POST request and start a new build. - The response is logged, but the workflow does not fail if the build trigger returns a non-200 response.
- The workflow can also be triggered manually.
Conclusion
Scheduled builds with GitHub Actions are a simple and effective way to keep your Cloudflare Pages site up to date. This is especially valuable for projects with dynamic or API-driven content. If you want to extend your automation even further, you can also look into Cloudflare Workers for custom serverless logic.

Comments