Script to install latest hugo release on macos and ubuntu


Made a script to install the latest hugo release (non-extended version) on macOS. It works on Ubuntu as well, just replace occurrences of macOS with Linux.

Edit: This assumes $HOME/bin/ is already on your PATH

Edit 2: It now does all work in /tmp/, then moves the hugo binary to /usr/local/bin/, so this script will likely need need to be run with sudo

# Change to temporary directory
pushd /tmp/

# Get JSON response of latest releases, find the one we want, 
# pretty-up the URL, then download it
curl -s \
| grep "browser_download_url.*hugo_[^extended].*_macOS-64bit\.tar\.gz" \
| cut -d ":" -f 2,3 \
| tr -d \" \
| wget -qi -

# Unzip hugo binary
tarball="$(find . -name "*macOS-64bit.tar.gz")"
tar -xzf $tarball

# Give hugo binary executable permissions
chmod +x hugo

# Move hugo binary to a location that is already on your PATH
mv hugo /usr/local/bin/

# Go back to previous directory

# Display hugo binary location and version
location="$(which hugo)"
echo "Hugo binary location: $location"
version="$(hugo version)"
echo "Hugo binary version: $version"

My inspiration:


Also note:


Nice. It’s like he took the Gradle Wrapper concept and applied it to Hugo


Also, mostly because I need to explain things to myself lol, did a small write-up:


I do it this way, with a zsh function (I’m using macOS):

Yours is more agnostic I think @zwbetz, but I just really like jq.


Nice. Btw, I’m digging your .zshrc file


beware, probably a lot of detritus in there! :blush:


Here’s my improved version. Checks if update is needed first. Avoids having to remember to preface with sudo. Checking local architecture and downloading the correct tarball is next improvement.


CUR_VERSION="$(hugo version | cut -d'v' -f2 | cut -c 3-5)"
NEW_VERSION="$(curl -s | grep tag_name | cut -d'.' -f2 | cut -d'"' -f1)"
echo "Current Version: $CUR_VERSION => New Version: $NEW_VERSION"

if [ "$NEW_VERSION" -ne "$CUR_VERSION" ]; then

  echo "Installing version $NEW_VERSION"

  pushd /tmp/

  curl -s \
  | grep "browser_download_url.*hugo_[^extended].*_Linux-64bit\.tar\.gz" \
  | cut -d ":" -f 2,3 \
  | tr -d \" \
  | wget -qi -

  tarball="$(find . -name "*Linux-64bit.tar.gz" 2>/dev/null)"
  tar -xzf $tarball

  chmod +x hugo

  sudo mv hugo /usr/local/bin/


  location="$(which hugo)"
  echo "Hugo binary location: $location"

  version="$(hugo version)"
  echo "New Hugo binary version installed!: $version"

  echo Latest version already installed


@dkebler – Just took it for a spin on macOS, nice improvements :+1:


Ok here is my “super improved” version as a downloadable link
(latest update 8:26pst Nov 9,2018)
I’ll make any corrections/improvements to the copy at this link.

Easiest way to use it is download to ~/bin or another directory in your path. Do a chmod +x and then you’ll be able to run it from anywhere. Then create a daily cron job and bob’s your uncle.

Will only work on generic linux including ubuntu/debian as it only downloads those tarballs.

  • Will determine if you are trying to install on an arm32, arm64, or amd64 machine and download the correct tarball.
  • Does some better error checking, aborts if there is nothing to update
  • You can set the default install directory in the script and/or install to an alternate directory from command line.
  • Uses sudo only if need be.
  • will use github user and token variables you can set in your enviroment or in script because as I discovered if you do too many anonymous curls to the github API it locks you out

Fair warning I did do some good testing/debugging but my effort was maybe 1/2 hour. Find anything amiss why then do share your corrections.


Link not working (at least for me):


Concur, not working for me either.


sorry that’s apparently a private thread and discourse won’t let me duplicate it
See above post where I fixed it with a direct downloadable link