Skip to main content

How to Install a Specific Version of Hugo on macOS

·430 words·3 mins· loading · loading ·
Tech tutorial hugo blog
Author
Avocado
重啟人生進行時
Table of Contents

To demo how to build a blog for beginners, I created a new user on my macOS and reinstalled Hugo in the new environment. However, the latest Hugo version, 0.120.3, unfortunately has some compatibility issues with the installed Blowfish module. For example, certain configuration parameters such as showDate, showView, showLikes cannot be rendered correctly on my site. While this issue may be resolved in future version updates, I would like to revert to my previous Hugo version, 0.119.0, for the time being.

brew install hugo@0.119.0 was my initial thought, but it didn’t work as expected. After some research, I found that Manuel Martinez’s method worked best for me. Below are the exact procedures with a few adjustments.

Procedures
#

1. Download a Specific Hugo Version
#

  • Visit Hugo releases on GitHub and search for the version that you want to install
  • Click on the specific version number link and scroll down to the Assets section
  • Choose the package that matches your operating system. The one I downloaded is hugo_extended_0.119.0_darwin-universal.tar.gz
  • Verify the package’s contents before extracting it using the command:
tar tvf ~/Downloads/hugo_extended_0.119.0_darwin-universal.tar.gz
Remember to change the path if your package is downloaded in a different location.

You’ll see something like below in the terminal:

-rwxr-xr-x  0 root   root 145442184 Sep 24 11:29 hugo
-rw-r--r--  0 root   root     12810 Sep 24 11:19 README.md
-rw-r--r--  0 root   root     11347 Sep 24 11:19 LICENSE

2. Edit the Shell Profile
#

  • Run echo $PATH to see the order of directories in your PATH. By default, you may see the result starts with /opt/homebrew/bin/hugo
  • Run the following command to determine whether your default shell is bash or zsh
echo $SHELL
  • Depending on the type of the shell, edit the profile using one of the commands below
nano ~/.bash_profile
#or
nano ~/.zprofile
  • Add export PATH="$HOME/bin:$PATH" to the beginning of the file
  • Press Ctrl + O to save the changes and exit by pressing Ctrl + X
  • Run one of the following commands to apply the changes to the current session
source ~/.bash_profile
#or
source ~/.zprofile

3. Install Hugo in the Local Bin Directory
#

  • Check whether you already have a bin directory in the home directory; if not, create one
ls ~/bin
#or
mkdir ~/bin
  • Move to the bin directory and extract the tarball
cd ~/bin
tar -xvzf ~/Downloads/hugo_extended_0.119.0_darwin-universal.tar.gz

4. Verify the Installation
#

  • Run which hugo to confirm Hugo is in the local bin directory
  • Re-run echo $PATH. It should now begin with the path /Users/<your-user-name>/bin
  • Run hugo version to display the Hugo version your system is using

Reference
#

Like this post?

loading  

Related

A Beginner-Friendly Tutorial for Building a Blog with Hugo, the Blowfish Theme, and GitHub Pages
·2885 words·6 mins· loading · loading
Tech tutorial coding hugo blog
Simplified Guide: Configuring a Custom Domain Name for GitHub Pages Site
·678 words·4 mins· loading · loading
Tech tutorial
Getting Started with Entity Framework Core in Visual Studio
·902 words·5 mins· loading · loading
Tech tutorial coding