Azure DevOps AzureStaticWebApp: specifying Hugo version
I use Azure Static Web Apps in a couple of places, this blog and the Chordle site. While updating the templates they use, I found that the deployment builds started to break because the included Hugo version was out of date.
The first I fixed up was this blog. I was getting this error:
template: partials/func/getStylesBundle.html:4:90: executing “partials/func/getStylesBundle.html” at
: can’t evaluate field Sass in type interface {}
This is deployed using GitHub actions, and I found this documentation helped me resolve it there - I simply had to add the Hugo version as an environment variable to the build task.
1 name: Build and Deploy Job
2 env:
3 HUGO_VERSION: '0.148.1'
The Chordle site is deployed via Azure DevOps though, and the error I was getting there was:
error building site: failed to create resource spec: error expanding “/blog/:year/:month/:day/:contentbasename/”: permalink ill-formed
The breaking syntax is different due to the use of a completely different template.
The required changes to the task syntax aren’t described in the linked article. After a bit of playing
around, I found that it was actually almost identical for the AzureStaticWebApp@0
task - just add an env
value for the required HUGO_VERSION
:
1jobs:
2- job: build_and_deploy_job
3 displayName: Build and Deploy Job
4 condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
5 pool:
6 vmImage: ubuntu-latest
7 variables:
8 - group: Azure-Static-Web-Apps-variable-group
9 steps:
10 - checkout: self
11 submodules: true
12 - task: AzureStaticWebApp@0
13 env:
14 HUGO_VERSION: '0.148.1' # <--------- Add this
15 inputs:
16 azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN)
17 app_location: "/"
18 api_location: ""
19 output_location: "public"
I hope that helps someone else!