smhk

Install Hugo testing distribution on Debian

On a default installation of Debian, trying to install hugo with apt install hugo will fetch the latest stable version of Hugo, which at time of writing is v0.18.1, and was released in December 2016! I would like to install the more recent version 0.47.1 which came out last month in August 2018. However it is on the testing distribution so by default cannot be installed. To enable installing the testing version of Hugo, follow these steps:

Edit /etc/apt/apt.conf ((which did not already exist)[https://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html#s-default-version]) to set stable as the default distribution. This will ensure that when the apt command is used, the stable distibution is always assumed unless otherwise specified:

/etc/apt/apt.conf
APT::Default-Release "stable";

Next, update the apt sources list to enable the testing distribution for the repository that contains Hugo. For this, I created a /etc/apt/sources.list.d/testing.list file with the following:

/etc/apt/sources.list.d/testing.list
deb     http://ftp.uk.debian.org/debian/    testing main contrib non-free
deb-src http://ftp.uk.debian.org/debian/    testing main contrib non-free

Now, after running apt update, you can install the testing distribution of Hugo using the -t option:

$ apt -t testing install hugo

To confirm:

$ hugo version
Hugo Static Site Generator v0.47.1/extended linux/amd64 BuildDate: 2018-09-25T03:41:10Z

Note that if you have not run apt update or have not added testing to a source list which contains Hugo, then you will get the following error:

$ sudo apt -t unstable install hugo
Reading package lists... Done
E: The value 'unstable' is invalid for APT::Default-Release as such a release is not available in the sources

A word of caution: beware about using testing or unstable distributions in general, but in particular for packages which have dependencies.