# Installing Hugo on Fedora 25

## Or on any flavour of Linux, for that matter

For those not in the know, Hugo is an amazing tool for building static websites—including the one you’re reading right now. There are no RPMs available, though, so if you’re using Fedora or another RPM-based Linux distro, then you might think you’re out of luck.

In my case, when I saw that there were no Hugo RPMs, I looked to see if there were any unofficial ones. There were, but only for Hugo v0.16, and I needed v0.17 or later for the support for multilingual sites. So no luck there. Then I investigated installing it using snap, but Fedora doesn’t support snaps out of the box, and I’m still slightly skeptical of the idea of using snaps on my system. Then I looked into installing Hugo from source, but it requires Go 1.8+, and Fedora 25 only has 1.7 in the official repositories. It was around this time that I started getting jealous of Ubuntu users’ ability to do a simple sudo apt-get install hugo. Would I have to replace my OS or set up a virtual machine just to make my website?

Thankfully, in the end, the solution was simple.

It turns out that Hugo is a single binary with no required dependencies. So—as I should have done in the first place, had I read Hugo’s documentation more closely—all you need to do is download the binary and put it somewhere in your PATH environment variable.

First, you need to go to Hugo’s releases page and download the latest release for your machine and OS. I’m running Fedora on a 64-bit machine, and at the time of writing v0.19 is the latest version, so I downloaded hugo_0.19_Linux-64bit.tar.gz.

## Step two: extract it

Next, extract the binary to where you want it to run. The Hugo installation guide suggests doing this somewhere that is already in your PATH, like /usr/local/bin, but I like to keep manual installs in my home directory, as a) you don’t need to have superuser permissions to install it, and b) it makes it a lot less likely that you will mess up your system if you make a mistake. I’m going to show you how to install Hugo in a subdirectory of your home directory called “software”; if you want to install it somewhere else, replace ~/software in the following commands with your preferred location.

If your destination directory doesn’t exist yet, create it.

$mkdir ~/software Next let’s make a folder for the version of Hugo we downloaded. This keeps our directory structure tidier, and lets us easily switch to different versions of Hugo. Here we use the directory name hugo_0.19; change that accordingly for the version you downloaded.$ cd ~/software $mkdir hugo_0.19 Then extract the Hugo tar.gz file into your new folder from where you downloaded it. In my case, I downloaded it to the default download folder at ~/Downloads.$ tar -xzf ~/Downloads/hugo_0.19_Linux-64bit.tar.gz --directory=hugo_0.19

The tar command from step two gave us a directory structure like this:

.
└── hugo_0.19
├── hugo


At this point we can run Hugo with the command ~/software/hugo_0.19/hugo, but the command will change every time we upgrade Hugo, which is not very nice. In order for us to run Hugo with the same command every time, let’s create a symlink to the Hugo binary from our software directory. The name of the symlink is going to be the name of the command we type to run Hugo, so let’s call it “hugo”.

$ln -s hugo_0.19/hugo hugo Replace hugo_0.19/hugo with the path to the file you extracted. ## Step four: add it to your PATH Now we can run Hugo with the command ~/software/hugo, which is a big improvement over having to type out the version number each time. However, you probably want to run it by just typing hugo, which means you need to add the ~/software directory to your PATH environment variable. (If you chose something other than ~/software for your installation directory, replace $HOME/software with it in the code below. Shortcuts like ~, . and .. won’t work here, but you can use the $HOME environment variable as a shortcut for your home folder.)$ PATH=$PATH:$HOME/software

Then for the system to use the new value of PATH, you need to export it:

$export PATH This is enough for the current session, but if you want to run Hugo again after you reboot your machine, then you need to make sure that your PATH is set when you start your session. An easy way to do this is to edit your .bashrc file. Open ~/.bashrc with your preferred text editor and add the commands again to the bottom of the file. (If ~/.bashrc doesn’t exist already, create it.) PATH=$PATH:$HOME/software export PATH Now let’s see if Hugo runs properly.$ hugo --help

If that command prints out a help message, then well done, you have successfully installed Hugo! Check out the quickstart guide for some next steps in building your website.

## Step five (optional): install Pygments

EDIT: This step is no longer necessary with Hugo v0.28 and later, as it has native syntax highlighting.

If you include code snippets in your website, you might want to install Pygments as well, so that you can get automatic syntax highlighting. You can install it via the pip package manager for Python.

$pip3 install --user Pygments The --user there installs the package for the current user, rather than installing it system-wide. Installing things system-wide with pip can sometimes clash with packages installed by the system package manager, so it’s best avoided. ## Upgrading Thanks to the symlink we set up in step three, to upgrade Hugo all you have to do is download and extract the new version, and then point the link to it. Here I’m assuming that you downloaded the 64-bit version of Hugo 0.20, and that you’re using the default downloads directory of ~/Downloads.$ cd ~/software $mkdir hugo_0.20$ tar -xzf ~/Downloads/hugo_0.20_Linux-64bit.tar.gz --directory=hugo_0.20 $ln -sf hugo_0.20/hugo hugo If you want, you can delete the old version of Hugo too. Assuming the old version is v0.19:$ rm -r hugo_0.19

Hopefully in the future you will be able to install Hugo with Fedora’s package manager, but until then, this should get you up and running. Happy blogging!