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:
Extract the hugo binary from the downloaded archive.
Put it in a directory that you already have in PATH.
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
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.
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:
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.
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.
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.
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.
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.