How to install Go(lang) and Hugo on Ubuntu.

Install Go

Reference: https://golang.org/doc/install

Replace the https://… download URL below with the latest Linux AMD64 version listed at https://golang.org/dl/

cd $HOME
sudo curl -OL https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf $HOME/go1.9.1.linux-amd64.tar.gz
rm $HOME/go1.9.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
mkdir $HOME/go/bin -p
mkdir $HOME/go/pkg
mkdir $HOME/go/src
export PATH=$PATH:$HOME/go/bin

Install Hugo

Reference: https://gohugo.io/getting-started/installing/

The first three lines below creates a shell script which will download the latest version of Hugo, compile it with Go, and then install it in the Go bin directory.

The subsequent commands will mark the created script file as executable and then finally run that script.

echo "go get github.com/kardianos/govendor" > hugo-from-gh.sh
echo "govendor get github.com/gohugoio/hugo" >> hugo-from-gh.sh
echo "go install github.com/gohugoio/hugo" >> hugo-from-gh.sh
chmod +x hugo-from-gh.sh
./hugo-from-gh.sh

To test that all is installed as expected, run the following commands and check that they don’t report a file not found error.

go version
hugo version