Installing multiple versions of Hugo on a single machine

I’d like to test v0.60.0 against the currently used version, as there is a major change – Goldmark as the default Markdown renderer.

How can I install multiple versions of Hugo on a single machine? If you need similar testing, how do you cope with it?

Is that a Windows machine (hard) or Linux (compile each version separate and rename to hugo-version)?

I use Windows mostly at work, but I can test on macOS at home instead.

Are you ready to use Docker? Docker on Hugo is one of the easy solutions for your case.

1 Like

@peaceiris Yes I’m willing to, but it looks like there’s some learning curve.

You mean the one mentioned in the v0.60.0 Released thread?

https://hub.docker.com/r/klakegg/hugo/

Which image among them would you recommend to start with?

I suppose you could rename your currently installed executable from hugo.exe to smth like hugo59.exe, then download the exe for version 0.60.x in the same place on your machine and then rename the executable hugo60.exe.
Afterwards, it’s just a matter of running hugo59 server or hugo60 server alternatively

3 Likes

For example, on macOS:

wget https://github.com/gohugoio/hugo/releases/download/v0.60.0/hugo_0.60.0_macOS-64bit.tar.gz
wget https://github.com/gohugoio/hugo/releases/download/v0.59.1/hugo_0.59.1_macOS-64bit.tar.gz
tar -zxvf ./hugo_0.60.0_macOS-64bit.tar.gz
mv ./hugo ./hugo60
tar -zxvf ./hugo_0.59.1_macOS-64bit.tar.gz
mv ./hugo ./hugo59

We got two version Hugo.

$ ./hugo60 version
Hugo Static Site Generator v0.60.0-F2DEA9B0 darwin/amd64 BuildDate: 2019-11-27T10:09:53Z

$ ./hugo59 version
Hugo Static Site Generator v0.59.1-D5DAB232 darwin/amd64 BuildDate: 2019-10-31T15:21:24Z
2 Likes

@peaceiris, @Mihai, Thanks for your answers.
If possible, I’d like to pursue some method that’s not alternating between two different names. Could someone please elaborate the Docker method instead? I couldn’t find details on the forum.

That would be of interest for me too.
For now, all I can think of îs having two containers with different names, each equipped with a version of the Hugo executable. That îs, only more ritualism but no esential improvement…
Ideas?

We can switch Docker images easily like the following. (Just switch tag)

# Use v0.59.1
docker run --rm -i -t -v ${PWD}:/src -p 1313:1313 peaceiris/hugo:v0.59.1 server --bind=0.0.0.0

# Use v0.60.0
docker run --rm -i -t -v ${PWD}:/src -p 1313:1313 peaceiris/hugo:v0.60.0 server --bind=0.0.0.0

I’m using my Hugo alpine Docker image.

2 Likes

@peaceiris, thanks for the answer.

1 Like

Here’s a shell script I wrote to install and change hugo versions.

Modify it to meet your needs, currently the install path is $HOME/bin, which you may want to change or turn into its own variable.

2 Likes