Compiling Hugo from source (linux)

I’ve just read the documentation about compiling the program directly from the source but i can’t understand how to do it.
It’s just 2 lines of code written and doesn’t explain too much.
I’d like to download the source, edit some part of codes, compile it and run.
Is there a smart way to do that?

Thank you in advance!

The simplest way:

Assuming you have go >= 1.3 and git installed.

  • go version
  • echo $GOPATH

The last one prints the path to where all Go packages (both binary and source) ends up.

Do this to fetch Hugo:

go get

You might have to add -u -v flags, not sure.

cd $GOPATH/src/
go build

Should get you a hugo binary in that folder.

The path above will be a Git repository, so you can do git pull, git fetch, git merge …

To run tests you will have to explicitly get a lib:

go get

Earlier you had to have Mercurial installed to build, but I believe that dependency have gone away (@spf13?)

1 Like

I’m installing Hugo on Amazon Linux and everything works running go get However when I run hugo version I get the latest dev build “Hugo Static Site Generator v0.16-DEV BuildDate: 2016-04-06T16:07:49Z”. I’d like to install the latest official release 0.15. I don’t see anyway to specify a tag or release to the go get command. Is there a better way to install a specific release from source?


We tag releases in Git. cd into the Hugo Git repository ($GOPATH/src/ and execute git checkout v0.15. Now you can compile the latest release.

go get doesn’t support versioning this way.

Currently no easy way, as we don’t vendor our dependencies, so getting the right Git revision for Hugo is only part of the work. Brew on OSX does that for you, but they have their own build pipeline.

But we have binaries that should work fine on Amazon Linux.

Thanks for the tip. This version works fine on Amazon Linux: