Operating System Ubuntu

How to Install Hugo on Ubuntu 26.04 LTS and 24.04 LTS

Three ways to install Hugo on Ubuntu 26.04 LTS and 24.04 LTS, how they differ in version, and how to create and build a first site.

Hugo is a static site generator: a single binary that turns Markdown files and templates into plain HTML you can serve with any web server. This guide installs Hugo on Ubuntu 26.04 LTS, with notes for Ubuntu 24.04 LTS, using the three methods that fit a server (the official .deb package, Snap, and the Ubuntu archive), then creates a first site and builds it. Ubuntu 18.04 is out of standard support and its Hugo 0.40 package is far too old for current themes, so use one of the releases above.

Requirements

  • A server or workstation running Ubuntu 26.04 LTS or 24.04 LTS.
  • A user with sudo rights. The examples use deploy.
  • Git, which Hugo uses for themes and modules.

Install Git and the download tool used below:

sudo apt update
sudo apt install -y git wget

Choose an installation method

Hugo moves quickly, and themes often require a recent release. The version you get depends heavily on where you install it from:

MethodVersion you getUpdates
Official .deb from the Hugo release pageWhichever release you download (0.170.0 at the time of writing)Manual: download and install the newer package
SnapLatest releaseAutomatic
apt install hugo on Ubuntu 26.040.154.5Security fixes only; the version stays the same
apt install hugo on Ubuntu 24.040.123.7Security fixes only

The current Hugo documentation assumes version 0.158.0 or later, which is newer than either archive package. Use the .deb or the snap unless you have a reason to stay on the distribution's version. Install Hugo with one method only; two copies on the same machine lead to confusion about which one runs.

About editions

Older tutorials tell you to download the "extended" edition for WebP images and Sass. As of Hugo 0.170.0 that is no longer necessary: the standard edition encodes WebP, Sass is compiled by Dart Sass, and the project states that the extended editions are no longer needed. The release page still carries files with extended in the name so that existing download scripts keep working. There are now two editions to choose from:

  • Standard — the default, and the right choice for almost everyone.
  • Deploy — the standard edition plus the hugo deploy command for uploading directly to Google Cloud Storage, Amazon S3 or Azure Storage. Its files are named hugo_withdeploy_….

Method 1: install the official .deb package

Check your CPU architecture. The command prints amd64 or arm64:

dpkg --print-architecture

Look up the newest version number on the Hugo releases page on GitHub, then download the package and the checksum file. Replace the version if a newer one is out, and replace amd64 with arm64 on ARM servers:

cd /tmp
HUGO_VERSION=0.170.0
wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.deb
wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_checksums.txt

Verify the download against the published checksum. The command must print OK for the .deb file:

sha256sum --ignore-missing -c hugo_${HUGO_VERSION}_checksums.txt

Install the package:

sudo apt install ./hugo_${HUGO_VERSION}_linux-amd64.deb

To upgrade later, repeat these steps with the new version number; apt replaces the installed package.

Method 2: install with Snap

Snap is preinstalled on Ubuntu Server. One command installs the latest Hugo release and keeps it updated:

sudo snap install hugo

The Hugo snap is strictly confined. Two consequences matter in practice:

  • Your sites must live inside your home directory (or on removable media). A project in /srv or /var/www will not work with the snap; build in your home directory and copy the output.
  • Access to SSH keys, needed if Hugo has to fetch private Git modules, is off until you grant it:
sudo snap connect hugo:ssh-keys

Automatic updates can change Hugo underneath a site that depends on a particular version. To pin the installed version, and to release the hold later:

sudo snap refresh --hold hugo
sudo snap refresh --unhold hugo

Method 3: install from the Ubuntu archive

This is the simplest method and the oldest version:

sudo apt update
sudo apt install -y hugo

It is fine for a site that already builds with that version. On this package the newer hugo new project command used below may not exist; use hugo new site instead.

Verify the installation

hugo version

The output shows the version, the edition and the build date. If it reports an older version than you just installed, another copy is earlier in your PATH; which -a hugo lists them all.

Create and preview a site

Create a project in your home directory, add a theme as a Git submodule and tell Hugo to use it:

cd ~
hugo new project quickstart
cd quickstart
git init
git submodule add https://github.com/gohugo-ananke/ananke themes/ananke
echo "theme = 'ananke'" >> hugo.toml

Add a first post:

hugo new content content/posts/my-first-post.md

New content is created with draft = true in its front matter, and drafts are left out of builds. Start the development server with drafts included:

hugo server -D

The development server listens on localhost:1313 only. On a remote server, the safest way to look at it is an SSH tunnel from your own computer:

ssh -L 1313:localhost:1313 deploy@203.0.113.10

Then open http://localhost:1313/ in your browser. Press Ctrl+C on the server to stop Hugo.

Build the site for publishing

Open hugo.toml and set baseURL to the address the site will be served from, for example https://example.com/, and set title. When a post is ready, change draft to false. Then build:

hugo

Hugo writes the finished site to the public directory inside the project. That directory is all a web server needs. To publish it with a web server that is already serving /var/www/example.com:

sudo apt install -y rsync
sudo rsync -a --delete public/ /var/www/example.com/

Hugo does not remove files from public that came from content you have since deleted. Delete the directory before a production build if you have removed pages:

rm -rf public
hugo

Updating and removing Hugo

  • .deb: install the newer package as in Method 1. Remove with sudo apt remove hugo.
  • Snap: updates arrive automatically, or run sudo snap refresh hugo. Remove with sudo snap remove hugo.
  • Ubuntu archive: sudo apt upgrade applies fixes. Remove with sudo apt remove hugo.

Read the release notes before a large jump in version. Hugo deprecates template functions and configuration keys over time, and a theme written for an old release can fail on a new one.

Frequently asked questions

My theme uses Sass. What do I need now that there is no extended edition?

Install Dart Sass next to Hugo; the Hugo documentation has a page on it. Hugo calls the Dart Sass executable when a template asks for Sass to be compiled. Themes that only ship plain CSS need nothing extra.

Can I use hugo server to serve the live site?

No. It is a development server with live reload, meant for previewing. Build with hugo and serve the public directory with Nginx, Apache, Caddy or an object storage bucket.

Do I need Go installed?

Not to run Hugo: the packages contain a ready-made binary. You need Go only if you build Hugo from source or use Hugo Modules, and building from source requires a newer Go release than Ubuntu's archive usually provides.

Does Hugo have to run on the web server at all?

No. Many people build on their own computer or in a CI job and upload only the public directory. Installing Hugo on the server is convenient when you want to edit and rebuild in one place.

Share story:

Continue reading other guides on How VPS.