This is a Scheduled Post
Published: 2024-03-03 9:00 AM
Category: Technology | Tags: bash, script, pelican, static, ssg, schedule
This is a scheduled post!
One thing I miss from a CMS blog is the ability to schedule posts for publication. It turns out a lot of other people running Pelican (my blog engine of choice) have also faced this problem and shared their solutions:
- Scheduling Posts with Pelican written by Tiffany B. Brown of Webinsta mentions a bash script to look for "scheduled" posts in the frontmatter and then a second cron job to build the site.
- Timed Posts with Pelican written by mcman_s which includes a link to a bash script which will publish shared posts from a cron job.
- Scheduled Posts with Pelican by Benjamin Gordon. The oldest of the promising results I came across and the simplest implementation.
It would be great to be able to use the WITH_FUTURE_DATES
setting in Pelican, but since this is built from a bare git repo, I don't actually have the entire content directory on my server anywhere. My build step creates it when a push is received, so method #3 won't work easily without a change to my workflow.
I decied to modify the script shared by mcman_s (and I'm assuming it's similar to what Tiffany Brown wrote about). Each day, a cron job will create a clone of the repo to get the most up to date source files. Then, it loops over the content directory and looks for posts which need to be published based on the date. When it finds one, the file is edited and then committed and pushed back to the repo to be built.
So, this post was automatically published from a cron job. Now, when the mood hits me to fire out a couple of posts, I can do that and just set the publish date as some time in the future.
Comments