How to automate future publish?

I’m migrating a my wordpress-based site oobly.com to Hugo.

1 feature of Wordpress I’ll definitely need is the Future Publish feature. In wordpress, if I write a post and set the date to a future datetime, then when that datetime comes to pass, the post get automatically published.

How can I achieve the same with Hugo?

If I write a series of posts in markdown in the relevant folder in my hugo site setup, and set the datetime in the frontmatter of each post to a future datetime using the publishdate front matter field as detailed in the docs here, what else do I need to do, to achieve this functionality?

Thank you and let me know if you need more information.

My production setup is going to be Hugo on a Windows Server, that will using github or bitbucket for continous deployment upon checkin. I haven’t figured this out yet, but would still like to know about future publishing options

–Shiva

Hello @Shiva,

what you need is a service that triggers Hugo to a rebuild of your site. Doing this in a predefined time interval a service should fire up Hugo to rebuild your site with new content once the publishdate has been reached.

Take a look at the Automated deployment with Wercker tutorial in the docs. Wercker is used for a wide range of deployment operations in this project. For instance:

  • for recompiling Hugo for different plattforms if new commits have been pushed in order to detect bugs and problems in an early stage
  • if a new commit was pushed to the docs branch, Wercker recognizes this, triggers Hugo to rebuild the documentation and deploys it automatically to the server
  • www.themes.gohugo.io is rebuild constantly (in a defined interval).

The last two points should be interesting for you. Furthermore, there are already plenty of examples in this forum. Feel free to search or to ask.

3 Likes

Thanks @digitalcraftsman !!

Ok, when I come to that stage I will take a look. Right now I am also building a semi-manual CMS in ASP.Net that will curate content and generate the markdown posts for Hugo.

I guess in that application, I should set the publishdate to a future date, and have a task that periodically checks the dates and then generates the markdown file(s) once the time has passed and then trigger a hugo rebuild.

The simplest (and the simplest is almost always the best) is to build at a regular interval (every hour ?) – a dumb task with no logic. Hugo builds are fast.

Then you can do the tuning on the deployment side (if needed), which is simpler. I use Gulp to deploy to Amazon S3, which uses MD5 file hashes in /public to check which files to update (only the changed ones):

3 Likes

Wow, thanks for the script. I haven’t used gulp. I guess this is a good time to learn it.

I’m thinking of using netlify to host.