Homebrew manages a lot of the software on my Mac. In the case of Hugo—the tool used to generate this website—updating to the latest version broke the template (PaperMod), since Hugo introduced breaking changes that the template didn’t yet support.

I had two options: either fix the template or stick with an older version of Hugo until the template is updated. I chose the latter, since the site is hosted on Cloudflare, which uses a predefined Hugo version for generating the content. It’s more reliable to use the same version locally and in production.

The Mechanical Turk eventually produced a working script—though only after several rounds of corrections on my part.

Environment: macOS 15.4, Homebrew 4.4.x

install-hugo-0.145.0.sh

#!/bin/zsh

HUGO_VERSION="0.145.0"
FILENAME="hugo_extended_${HUGO_VERSION}_darwin-universal.tar.gz"
DOWNLOAD_URL="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${FILENAME}"
INSTALL_PATH="/usr/local/bin/hugo-${HUGO_VERSION}"

echo "📥 Downloading Hugo $HUGO_VERSION ..."
curl -LO "$DOWNLOAD_URL" || { echo "❌ Download failed"; exit 1; }

echo "📦 Extracting archive ..."
tar -xzf "$FILENAME" || { echo "❌ Extraction failed"; exit 1; }

echo "🧼 Removing quarantine attribute ..."
xattr -d com.apple.quarantine hugo 2>/dev/null

echo "🔐 Setting executable permission ..."
chmod +x hugo

echo "🚚 Moving to ${INSTALL_PATH} ..."
sudo mv hugo "$INSTALL_PATH" || { echo "❌ Move failed"; exit 1; }

echo "✅ Hugo $HUGO_VERSION installed at $INSTALL_PATH"

echo ""
echo "➡️  You can run it via:"
echo "    $ $INSTALL_PATH version"
echo ""
echo "➡️  Or create an alias:"
echo "    echo 'alias hugo=\"$INSTALL_PATH\"' >> ~/.zshrc && source ~/.zshrc"
echo ""
echo "🧪 Test:"
echo "    hugo version"

If you add the alias to your shell configuration, that specific Hugo version will be used. Once you remove the alias, the version installed via Homebrew takes over again.