25 Apr 2020 - Giulio Vian - ~2 Minutes
I wrote a while ago about Automating Hugo to publish a blog. In that post, I used Azure Pipelines (well, they had a different name at that time).
Today, after three years, I revised the solution and I am amazed by Hugo progress. Many of my customisations and hacks I implemented are gone: Hugo batteries included philosophy is a true thing.
In addition to using the most recent version – 0.68.3, while I was stuck at 0.24.1 – I decided to move everything to GitHub. I am urged by two motives. One reason is to test GitHub Actions in this scenario – and it went extremely well. Another stimulus came from Get Latest Version : we have a project requiring some publishing mechanism, a good excuse for reviewing publishing tools and web technology.
Publishing using GitHub Actions
Using GitHub Actions is very easy: just add a YAML file in the
.github/workflows diractory of your GitHub repository. That’s all.
Have to say a big thanks to Shohei Ueda aka
for the great job in creating simple and effective Actions.
The whole script is less than 20 lines which I will comment later.
There are a few notable things about the highlighted lines.
Line 11 (
submodules: true) guarantees that the Hugo theme is downloaded as well; if you don’t all formatting disappears. Lines 15 and 16 pick the desired Hugo version. I recommend being very explicit as new versions appear fast and sometimes require to update the theme or adapt existing code.
To publish the Hugo generated site (lines 19 to 25), I opted for a separate repository. This is more complex than other techniques, like using the
gh-pages branch in the same repository, but I feel safer for future changes.
Enough for today, catch you soon.