Skip to content

Running different versions of Hugo from command line (sans Homebrew) using zsh

Michael Hulse edited this page Mar 18, 2020 · 4 revisions

At my day job, I have to run a different version of Hugo depending on the project.

If you need to run different versions of Hugo, I highly recommend this approach; if you need to run an older version of Hugo, and/or you need to run multiple Hugo versions, using Homebrew will mess you up for when it comes to updates.

1. Download Hugo release versions

Download desired Hugo releases from here: gohugoio / hugo: releases

Extract the executable from the release package and put somewhere convenient, like: ~/scripts.

Rename the executables to something easy to remember, for example:

Optional: Run ln -s hugo67e hugo so you have a default hugo command.

2. Add to your path

In my .zshrc, I have:

# Executables:
path+=("$HOME/scripts")

Once that’s all setup, you can run: source "$HOME/.zprofile"

Bonus! Here’s a function that’s handy:

# Reloads session:
function reload() {
  source "$HOME/.zprofile"
}

3. Run Hugo!

Now, you can use hugo serve or hugo54 serve.

Clone this wiki locally