You’ve successfully created your website using Hugo and added a theme. Now it’s time to build and publish it. This guide will show you the best way to deploy your Hugo site using GitHub Actions and GitHub Pages.
The official way (and why you might want to skip it)
If you open the official documentation, you’ll quickly notice the recommended workflow is more than 105 lines and quite complicated. It manually installs Go, Node.js, Dart, Sass, Hugo, and additionally requires you to configure specific versions for each tool.
While this approach gives you full control, it comes with several drawbacks:
- Complex: 106 lines of configuration with many dependencies
- Manual: All dependencies need to be configured manually
- Inflexible: Manual version management for multiple tools
- Slow: Build times around 30 seconds
- High maintenance: More overhead to keep everything updated
A better approach with peaceiris/actions-hugo
Fortunately, there’s a better way to set up your GitHub Actions workflow for Hugo. You can use the peaceiris/actions-hugo GitHub Action, which simplifies the process and reduces configuration overhead.
Why choose this action?
- Compact: Around 30 lines instead of 105+
- Simple: All dependencies are already preconfigured
- Flexible: You can set Hugo’s version to “latest” for automatic updates (by default it uses a specific version)
- Fast: Build times around 5 seconds
- Reliable: Widely used and trusted by the community. While this action isn’t officially maintained by Hugo or GitHub, it is popular (1.5k+ stars) and works great.
Even ChatGPT agrees with this approach: if you want to build and host your personal website, peaceiris/actions-hugo is a great choice.