Write Today, Publish on Tuesday: Scheduled Posts on a Static Site
WordPress has a Schedule button. A static site gets the same result from Hugo's date check and one GitLab job that runs each morning.
WordPress has a Schedule button. A static site needs a different arrangement, and it comes down to one job and one timetable.
Hugo already does half the work. It leaves out any post dated later than the moment it builds, so a post dated next Tuesday stays off your site entirely, feed included, until the site is built on or after that date.
The other half is the build. We build when you push or press Deploy, and nothing rebuilds on its own. So on the morning a post falls due, something has to start a build.
A timetable in GitLab
GitLab can run a job on a timetable, called a pipeline schedule. Ours runs at 07:00 every day. If a post is dated today, the job pushes an empty commit. That push reaches us through the webhook like any other, and the site rebuilds with the new post in it. On a day with nothing due, the job does nothing.
Our guide, Scheduled posts with Hugo and GitLab, has the whole setup with the job to copy: a project access token, a CI/CD variable, the job itself and the schedule.
Our own blog runs on it
Every post we have published since 6 November was written days or weeks before its date and went live on its morning this way, including this one.
See what is waiting
To list every post dated ahead, run hugo list future in the site’s folder. To read them before their day, run hugo server --buildFuture and open the local preview: future posts show there as if they were live, and nowhere else.
That is also the safest way to check a batch written in one sitting. Read them in the preview, push them together, and let the schedule release them one at a time.
What trips people up
- A date with no time counts from midnight UTC, unless you have set
timeZonein your Hugo config. - A build command with
--buildFuturein it publishes every post the moment you push. - Any push publishes the posts that are due, schedule or not.
- The token expires. When it does, posts stop appearing on their day until you replace it.
Schedule the social posts after the page
If you announce posts on social media, schedule those for after the morning build, so the link works when people click. We send ours from midday.
Yesterday’s post was about what static hosting can’t fix.
Ready to Deploy?
Join Jamstack developers across the UK hosting their static sites with privacy and performance built in. Hosting is free for good, no credit card needed, with Plus features when you want them.
