General: Controlling Hugo version in Azure Static Web Apps

General: Controlling Hugo version in Azure Static Web Apps

A while back, I moved almost all of the simple websites that I work with, away from WordPress and over to Azure Static Web Apps. Overall, it has been a really good option for me.

For a start, having all my blog posts, etc. now properly in source control is wonderful. And I really enjoy being able to edit in Markdown.

For this to work though, you need a static website generator. After spending quite some time checking out YouTube videos, I opted to use Hugo as the generator. I was going to use MainRoad as the template for the site, but while it looked great, the development for it seemed to be pretty dead.

I decided to use the Roadster theme. It’s a fork of the MainRoad theme that has ongoing development. I then made my own fork of that theme so that I could change it as needed.

It’s been quite a learning curve, but worthwhile.

Hugo Versions

One early issue that I ran into was that the version of Hugo that I was using was much more recent than the one that was supplied by default by Azure Static Web Apps.

In fact, when I first tried the Hugo tutorial on the Microsoft Learn website , I found that deployment failed because the theme that they use (ananke) had a minimum Hugo version that was later than the one supplied at Azure Static Web Apps.

I asked many people how to change the version of Hugo that was being used, and I received many opinions, none of which were correct. Often, they suggested executing code myself as part of the deployment process. I kept thinking that it must be easier than this, and that the team must have thought of it. And of course they had.

All you need to do is to add an env: tag to the Build and Deploy step in the deployment workflow, and set the variable HUGO_VERSION to the required version, as shown in the image above.

I hope that helps someone else. I’m just surprised that the option isn’t auto-generated as part of the workflow that is created.

2025-06-07