(Last Updated On: November 9, 2018)

In this guide, I’ll take you through the steps to install and use Hugo on Ubuntu 18.04 LTS Desktop and Server editions. Hugo has been confirmed to be the fastest open-source static site generator written in Go. Hugo is capable of generating a static site at a speed of <1 ms per page, the average site builds in less than a second. It ships with pre-made templates to make quick work of SEO, commenting, analytics and other functions.

Hugo supports unlimited content types, taxonomies, menus, dynamic API-driven content, and more, all without plugins. Additionally, you can output your content in multiple formats, including JSON or AMP

How To Install Hugo On Ubuntu 18.04 LTS

Hugo can be installed on Ubuntu 18.04 by downloading a .deb package or from apt repository.

Installing Hugo On Ubuntu 18.04 LTS from apt repository

Update your system apt index and install Hugo:

$ sudo apt-get update
$ sudo apt-get install hugo

You can confirm the location of hugo binary after installation using which

$ which hugo
/usr/bin/hugo

Installing Hugo On Ubuntu 18.04 LTS from .deb package

To install Hugo on Ubuntu 18.04 from Debian package, first, download the latest release from Github releases page https://github.com/gohugoio/hugo/releases/. Select a version that matches your CPU architecture:

$ export VER="0.51"
$ wget https://github.com/gohugoio/hugo/releases/download/v${VER}/hugo_{VER}_Linux-64bit.deb

Then install the package using dpkg

$ sudo dpkg -i hugo_${VER}_Linux-64bit.deb 
(Reading database ... 133419 files and directories currently installed.)
Preparing to unpack hugo_0.51_Linux-64bit.deb ...
Unpacking hugo (0.51) over (0.51.1-1) ...
Setting up hugo (0.51) ...
Processing triggers for man-db (2.8.3-2) ...

If the installation was successful, you should be able to use hugo command:

$ hugo --help

How to Use Hugo on Ubuntu 18.04

Now that Hugo is installed, you can start creating website content. Before that, you’ll need to create new content for your site. In this example, my site is called hugo.computingforgeeks.com

$ hugo new site hugo.computingforgeeks.com
Congratulations! Your new Hugo site is created in /home/jmutai/hugo.computingforgeeks.com.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.

To create a test page, cd to site directory and use

$ hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>

Example:

$ cd hugo.computingforgeeks.com
$ ls
archetypes config.toml content data layouts static themes

Site content is placed inside content directory

$ hugo new posts/test-page.md
/home/jmutai/hugo.computingforgeeks.com/content/posts/test-page.md created

Add dummy content for test:

$ vim content/posts/test-page.md

Add:

---
title: "Test Page"
date: 2018-07-12T10:17:29Z
draft: true
---

# Hello World

This is my first hugo site, wooo!!

```
hugo_install="success"
if [[ $hugo_install == "success" ]]; then
  echo "Happy me"
```

bye!

Build site:

$ hugo

                   | EN  
+------------------+----+
  Pages            |  3  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  0  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 9 ms

This will create public folder and add content to it. To serve website using hugo build-in server, use:

$ hugo server

                   | EN  
+------------------+----+
  Pages            |  3  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  0  
  Processed images |  0  
  Aliases          |  0  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 10 ms
Watching for changes in /root/hugo.computingforgeeks.com/{content,data,layouts,static}
Watching for config changes in /root/hugo.computingforgeeks.com/config.toml
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

For self hosting on a web server like Nginx or Apache, copy content inside public directory to your Web server document root.

Also check:

How to Install Jekyll on Ubuntu 18.04

How to Install and configure Ghost CMS on Ubuntu 16.04 / Debian 9