Switching Hugo versions

Continuing the discussion from Version 0.97 issues:

@pitifi9191 What OS are you using?

I use CentOS Linux but regardless of the OS, I believe that switching Hugo versions should be as simple as downloading the .tar.gz or .zip release archive pertaining to your OS from Releases · gohugoio/hugo · GitHub.

On Linux, a simple curl or wget works. On Windows, I can imagine that you just click on that archive link.

Then you just:

  1. Extract the hugo binary from the downloaded archive.
  2. Put it in a directory that you already have in PATH.

On Netlify, just change the HUGO_VERSION env var.

1 Like

If you use Homebrew on a Mac, downgrading used to be easy, but is now a bit of a chore:

  1. Go to Search · hugo · GitHub
  2. Search for the version you want and click on it (example: hugo : update 0.95.0 bottle).
  3. From the ... menu, select “View file”
  4. Click the “Raw” button (example).
  5. Download this file to hugo.rb.
  6. brew install hugo.rb
2 Likes

thanks @jgreely

this is what i needed as i downgraded using method in the past but wasnt able to locate the same method

thanks alot

thanks @kaushalmodi for taking the time jgreely’s solution is what i was looking for cheers!

np. I don’t have a macOS machine, but googling about brew, I found homebrew - How can I brew link a specific version? - Stack Overflow which was updated about 3 months back (Jan 2022).

Based on that:

brew install hugo@v0.96.0

or

brew install hugo@0.96.0

or find the find the version you want using below command and then install that.

brew search hugo@

Doesn’t that work for hugo?

Brew switch works if the earlier version is still installed on the Mac, but each upgrade deletes the older version. I’m not sure if this is unique to my Mac or to all Macs, but each upgrade deletes the prior version. You must look for tap and make exceptions in system preferences, among other things.

I’ve found that copying and pasting the raw hugo.rb file on a Mac is a much easier technique. but i forgot to save this method and today i wasnt able to remember how i downgrade the last time :stuck_out_tongue:

OK, it makes sense then why you would need to do that manual brew install.

Though, nowadays so many tools (hugo, rg, bat, etc.) have the static binaries available in Releases… I wonder why not K.I.S.S. and just download+extract from the releases… Some light searching led me to tools like eget.

It’s just another program I’m not sure I can trust with the kind of access to system settings it requires from me. Brew is a large company, so if they make a mistake, one would expect to know about it and have a solution ready far faster than eget, which is run by two people.

Copying and pasting the hugo.rb file from github makes privacy and security much easy to manage.

1 Like

Dependencies. An awful lot of the packages supported by Homebrew require other packages, or the releases are only available as source on github. Simple example:

% brew deps --tree curl
curl
├── brotli
├── libidn2
│   ├── gettext
│   └── libunistring
├── libnghttp2
├── libssh2
│   └── openssl@1.1
│       └── ca-certificates
├── openldap
│   └── openssl@1.1
│       └── ca-certificates
├── openssl@1.1
│   └── ca-certificates
├── rtmpdump
│   └── openssl@1.1
│       └── ca-certificates
└── zstd
1 Like

Just chiming here as we might have a solution that fits. We use a bash script to download a specific version of Hugo and store it in the project’s bin directory so you end up with something like that:

bin
    hugo_0.95.0

Then you can make a Make or an nmp script that will invoke: bin/hugo* server -D

The bash script takes a potential argument for the version or reads the package.json file where the information has been set.

This is the best way to easily change Hugo version. It’s also great for team projects as you can ensure everyone is using the same Hugo version.

Here’s the script: GitHub - theNewDynamic/gethugo: Bash Script to load Hugo locally in a project

i mean this seems extra work and knowledge requirement than simply running

brew uninstall hugo

and then

brew install https://the github-hugo-verion-0.97.1-raw

or did i just miss the point here?

thanks

If you try to download a brew formula directly in brew install, it will fail because it doesn’t have a SHA checksum. The official method for doing this is to create your own tap on github.

Hi @jgreely

thats not true, if you using mac try to run the

brew uninstall hugo

and then

brew install http-url

and it works normal i use it 3-4 time in last 2 days and it work very good

maybe your reference is to hugo on a different platform like windows or linux

thanks

I tried it, it failed with the error I described. Perhaps if you pasted the exact command you’re running, rather than “http-url”, people could follow your instructions.

2 Likes

We use hugo-installer - npm which installs the specified Hugo version in a bin folder which is set in our Git ignore. We then create npm scripts like “npm run dev” or “npm run build” which run Hugo server or Hugo commands respectively.

This works for us, it’s not perfect, but for our team we all have one command and the same version of Hugo.

1 Like

hello @jgreely

Please accept my apologies; I believed what I wrote was clear. Please follow the steps outlined below.

  1. Run the command brew uninstall hugo to uninstall the current hugo version.

  2. Visit this GitHub page and click History to find the version you want.

  3. Assume you require version 0.96.0. Select that version by clicking on it.

  4. Click the three dots… next to Formula/hugo.rb and select View File.

  5. Now, click raw to see the file’s raw code.

  6. The raw file will open a new url which you can copy.

  7. The final step is to use the raw code URL you copied in the previous step to install the hugo version of your choice.

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e080b8ab4ed7c8bee5b877060a9b6c840157d1e7/Formula/hugo.rb

I hope this helps, and have a nice day.

Just for the record. If you use Hugo modules and mounts, you need a recent Go environment anyway. Given that, you can git clone Hugo from GitHub and compile every release you like with go install and --tags extended, if you need it.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.