3.1. Build Hugo
If the used distribution does not provide the latest or needed version of Hugo, these steps describe how to build Hugo from its git repository.
Precondition
Hugo is a tool based on the go language.
Before Hugo can be built, the golang
packet of your distribution needs to be installed.
The installation of this package is as easy as calling:
sudo apt install golang
sudo dnf install golang
Build Hugo
To build the latest stable Hugo version, following command must be invoked:
go install -v github.com/gohugoio/hugo@stable
Depending on which go modules are already downloaded, this call can take some time to finish.
To build from any other label, stable
must be replaced by the targeted label.
Calling Hugo
After the build, Hugo’s executable located in the directory ~/go/bin/
.
If the PATH
variable already points to this directory, hugo
can be called immediately.
Alternatively the executable can be copied to a location that is already in PATH
.
For example:
cp ~/go/bin/hugo ~/.local/bin/
The version of hugo
can be found out by
hugo version
which provides an output like
hugo v0.121.1 linux/amd64 BuildDate=unknown