How we publish blog posts on a schedule on a static site
This blog is a static site: every page is built ahead of time and served as plain files. That keeps it fast and simple, but it raises a small question. How does a post go live on a set date if nobody runs a deploy that day?
This post is our answer, and it is also the test. It was merged a few days before the date at the top of this page, and it went live on its own.
Merge early, publish on the date
Each post has a publication date in its front matter. When the site is built, the blog leaves out every post dated after today. “Today” is the calendar date in Madrid, not in the time zone of the build machine, so a post goes live from midnight Madrid time on its date.
A scheduled post leaves no trace before its date: no page, no row on the blog index, no RSS item and no sitemap URL. If a post has a translation that is still scheduled, the language links point to it only once it is live.
This means we can review and merge a post as soon as it is ready, without waiting for the publish day.
A preview for review
Reviewers still need to see a scheduled post before it is public. Our staging build uses a preview flag that includes scheduled posts, with a “Scheduled” label and a noindex tag. The production build never sets that flag.
Checks that stop a leak
Two checks run on every build. The first fails the build if a live post links to a post that is still scheduled. The second reads the finished site and fails if a draft or scheduled post shows up anywhere: as a page, in a link, in the RSS feed or in the sitemap.
The nightly run
A static build only changes when the site is built again. So every night, a few minutes after midnight in Madrid, a scheduled job compares the posts due that day with the live RSS feeds. If they are all there, it stops. If one is missing, it rebuilds and deploys this website only.
It does that only when the code is the same version that is already live. New changes still go through the normal review and approval before production. The nightly run can publish what was already approved; it cannot ship anything new.