General: Auto-populating future posts in Hugo-based Azure Static Websites

General: Auto-populating future posts in Hugo-based Azure Static Websites

I posted a while back about moving to using Hugo-based Azure Static Websites for my blog and other simple sites. I love having source code based websites.

However, one thing I wasn’t expecting was about how future blog posts would be handled. I tend to generate posts well in advance, and I wanted them to appear all by themselves when the appropriate date came.

I thought that even a static website would just show you things within the date range. But that’s not how it works. When you build a Hugo based site, it generates a site that includes all the posts that should be shown up to the time you build it.

What was needed was to add a schedule into the GitHub action that Azure Websites generates for building the site. In the image above, you can see the first part of what’s required.

I added a schedule. Note that the default is to work with UTC so my cron entry says 2AM. That makes it 1PM Australian Daylight time, so that works fine for me. I have automated notification posts with links to these posts across to LinkedIn, BlueSky, and Facebook. They run at 3PM each day. So that means that by the time those posts are delivered, the website will already be updated.

Now that’s all good, and the action will run each day, but it still wouldn’t work. That’s because of the way the trigger works. One more change was required.

This code:

  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest

isn’t going to fire on a schedule. The action will run but the build won’t occur. It needs one more OR option in the if statement:

  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'schedule'
    runs-on: ubuntu-latest

And then we’re good.

2025-07-17