Scheduling posts on a static blog
One of the things I missed moving from WordPress to Hugo: scheduled posts. WP just… does that. Set a future date, and forget about it.
And static site generators don’t… The site only rebuilds when you git push, and that’s it. 😢
Why schedule posts, you ask? Because at times I write 3-4 posts in a day, and I don’t want to spam. ¯\(ツ)/¯ I have a rule that there should only be a single published post a day, and if I know I’m out of topics (especially for FlatTurtle) I tend to add a week or 2 between posts to spread it out evenly.
So I wrote (aka vibe coded) a little thing about a year or two ago, originally called BlogTurtle Rebuilder, because it was meant for FlatTurtle’s hugo blog. I’ve since repurposed it for this site.
The flow is quite simple:
- I push a Markdown post to GitLab with
date = "..."set to whenever I want it published. - Gitlab runs CI and deploys to Cloudflare Pages. Hugo will, however, hide posts with a
datein the future. - On push, GitLab also pings a webhook (a docker container on a server).
- Said container does a
git pulland scans every.mdfor that date field. - Anything in the future gets an in-memory timer for that exact moment. Anything already due gets ignored at Gitlab CI would’ve deployed it.
- When the timer pops, it triggers the GitLab CI/CD pipeline (through another webhook) that does a new Hugo build + deploy.
- As an added bonus, I get an email telling me the post is live, with a Things3 deep-link to add a follow-up task to share it somewhere. It’s one click away.
That’s the whole thing.