Table of Contents
Hugo is a popular static site generator known for its speed and flexibility. One of its powerful features is the ability to schedule content publishing, allowing you to automate when your posts go live. This feature is especially useful for maintaining a consistent publishing schedule without manual intervention.
Understanding Scheduled Publishing in Hugo
In Hugo, scheduled publishing is achieved by setting a publish date in the front matter of your content files. When Hugo builds your site, it includes only the content that is due to be published based on the current date and time.
Steps to Schedule Content in Hugo
- Create a new content file: Use the Hugo command line or your preferred method to generate a new post, e.g.,
hugo new posts/my-article.md. - Set the publish date: In the front matter of your markdown file, add a
datefield with the desired publish date and time in ISO 8601 format, e.g.,2024-05-10T14:00:00. - Include the publish date in the front matter: Your front matter should look like this:
“`yaml — title: “My Scheduled Post” date: 2024-05-10T14:00:00 — “`
Building and Deploying Your Site
Once you’ve set the publish date, build your site using the hugo command. When the build is complete, your site will only display posts with a date earlier than or equal to the current date and time. To keep your content up-to-date, regularly rebuild and deploy your site.
Additional Tips
- Use accurate time zones: Ensure your
datefield uses the correct time zone or UTC to prevent scheduling errors. - Preview scheduled posts: You can preview your site to see which posts are scheduled by running
hugo server. - Automate deployment: Combine Hugo with CI/CD tools to automate building and deploying your site at scheduled times.
By following these steps, you can efficiently manage your content schedule, ensuring your audience receives fresh content consistently without manual intervention.