Install Hugo from Source on Ubuntu 19.10

Starting with instructions from the Hugo Installation Guide - Install from Source, verify the required tools are installed:

  • git
  • go (at least version 1.11 currently)

I found gcc and g++ are also required when running the final go install --tags extended install command, so ensure those are available as well.

It doesn't seem like there is a good PPA available for installing go (there are a number of various outdated 3rd party PPAs, but none look desireable). The github wiki for the golang project has an entry going over some installation options for Ubuntu (and generally debian based systems). It mentions that there's a snap for the latest version of go, so let's give it a try:

# This will give you the latest version of go
$ sudo snap install --classic go

Check to see if the install worked and go is available:

$ go version
go version go1.13.7 linux/amd64

Looks like we're all set to install hugo from source, enter the repo directory, and run the install command:

$ go install --tags extended

Here I ran into errors due to the requirement for gcc and g++ to be present:

exec: "gcc": executable file not found in $PATH

and after installing gcc:

go build github.com/wellington/go-libsass/libs: g++: exec: "g++": executable file not found in $PATH

Once gcc and g++ have been installed with apt install gcc g++, the hugo install command works without a hitch.o

$ hugo version
Hugo Static Site Generator v0.65.0-DEV/extended linux/amd64 BuildDate: unknown

Note that this installs the latest development version of hugo which may not be desireable depending on your use case.

Instead if you'd like to use the hugo release, we'll have to checkout the latest commit. With some help from stackoverflow we'll find and checkout the most recent tag corresponding to the latest stable release:

$ git fetch --tags
$ git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
$ git reset --hard
$ git clean -df

Now run go install --tags extended again and hope for the best:

$ hugo version
Hugo Static Site Generator v0.64.0/extended linux/amd64 BuildDate: unknown

Great success.

Closing Notes

Alternatively to installing from source; there is a hugo snap available for dead simple install and maintenance:

$ snap install hugo --channel=extended

Tags

 Ubuntu 19.10  Ubuntu  snap  hugo 
Table of Contents