22 Feb 2025
My Hugo site stopped running locally, because Hugo and the theme I am using (Academic CV) switched dramatically from Bootstrap to Tailwind CSS, as well as a bunch of other behaviour changes. I don't have the time to update everything. But Homebrew had already updated Hugo to the latest version. And there's no option to simply tap an older version in Homebrew.
This guide documents the process of manually installing Hugo 0.120.3 on a Mac with an M1/M2/M3 processor and ensuring Homebrew does not update it. I thought I'd share it for anyone else with this problem. The usual disclaimers - you do this at your own risk, etc. etc.
I didn't need this step, because I'd previously installed Hugo with Homebrew. But if you haven't: brew install hugo
Create a temporary directory and clone the Hugo source code for version 0.120.3:
mkdir -p ~/tmp/hugo-aargh
cd ~/tmp/hugo-aargh
git clone --branch v0.120.3 --depth 1 https://github.com/gohugoio/hugo.git
cd hugoRetrieve the commit hash and current build date:
COMMIT_HASH=$(git rev-parse HEAD)
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")Build Hugo with the necessary flags:
go build -tags extended -ldflags "-s -w \
-X github.com/gohugoio/hugo/common/hugo.commitHash=${COMMIT_HASH} \
-X github.com/gohugoio/hugo/common/hugo.buildDate=${BUILD_DATE} \
-X github.com/gohugoio/hugo/common/hugo.vendorInfo=brew" \
-o hugoMove the compiled binary to /opt/homebrew/bin/ and make it executable:
sudo mv hugo /opt/homebrew/bin/hugo
chmod +x /opt/homebrew/bin/hugoCheck that Hugo is installed and running the correct version:
hugo versionTo ensure that Homebrew does not automatically update Hugo, pin the package:
brew pin hugoYou can confirm that hugo is pinned by running:
brew list --pinned- This method manually compiles Hugo instead of using
brew installto avoid unwanted automatic updates. - If a future update is needed, you can unpin it with:
brew unpin hugo
- To remove the temporary build directory:
rm -rf ~/tmp/hugo-aargh
Hugo 0.120.3 is now installed and locked from Homebrew updates! ๐
๐ Thanks for sharing! Saved me countless hours of figuring out how to deal with the breaking changes in newer hugo versions. In my case, with the "Hugo Research Group Theme".