Install and Use Hugo Static Website Generator on Ubuntu 20.04

Hugo is a powerful tool for generating static websites. Static websites are those that do not process the data in terms of forms and generate documents. These websites consist of static informative pages. It is open-source and intended to design informative websites and small projects. The Hugo program is written in Go that makes it faster and secure. When you use Hugo, you do not need to install dependencies such as databases, python, and PHP to run Hugo websites.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related web development queries on Linux systems.

In this context, we shall look into how to install the Hugo website generator application on Ubuntu 20.04 system.


How to Install Hugo on Ubuntu ?

We can apply different methods to install Hugo on your Linux system. Here we will be considering the following ways:

  • Hugo installation via the Ubuntu apt repository
  • Hugo installation via downloading the .deb package


1. Hugo installation via the Ubuntu apt repository

The Hugo application can be installed directly using the official Ubuntu apt repository. 

To begin, Open the terminal window and first update the all apt packages list. 

Then, install Hugo using Ubuntu apt repository by executing the below commands:

$ sudo apt update
$ sudo apt install hugo

This method of installing hugo is easy and straight-forward but it will not install the latest Hugo application version on your system. Therefore, most Linux Administrators do not use it.

You can verify this method using the following command:

$ hugo --version

From the output, you will see that the system do not have the latest version on Hugo installed.


2. Hugo installation via downloading the .deb package

The best method of installing Hugo is via dowinloading its .deb package. The .deb Hugo package is available for download on a git repository to install the latest Hugo version. So you have to Download the latest Hugo .deb package from the git repository by running the below command:

$ wget https://github.com/gohugoio/hugo/releases/download/v0.79.0/hugo_0.79.0_Linux-64bit.deb

Next, Install the downloaded .deb package on your system by using the command as follows:

$ dpkg -i hugo_0.79.0_Linux-64bit.deb

After installing the required Hugo package, verify the Hugo installation by running the below command:

$ hugo version


How to Start using Hugo on Ubuntu ?

To Create a new website using Hugo, simply execute the below commands:

$ hugo new site [path_website]
$ hugo new site SampleSite

What the above command will do is to create a new folder with the name 'SampleSite'. 

Next, Navigate into it and start working in this folder. Also Add a new website theme. 

For that purpose, download multiple themes theme for testing using the git clone command as follows:

$ git clone --recursive https://github.com/spf13/hugoThemes themes

The above command will download all themes and it is necessary to put all themes in the 'theme' folder. Choose one theme for your website that you want to apply. Open the config.toml file in any text editor and paste the following lines:

baseURL = "http://example.org"
languageCode = "en-us"
title = "My new hugo Site"
theme = "KeepIt"

Now, create a new website index for your site by running the below-mentioned command:

$ hugo new _index.md

Here, you can add content using markdown:

## Hi Welcome to Linuxapt.com

You can also create new categories and post by using the following commands:

$ hugo new [category]/[file.md]

For creating a new post, execute the command:

$ hugo new posts/[postname.md]

To view the whole website structure, run the below-given command:

$ hugo serve


[Need assistance in fixing your website? We are available. ]

This article covers the best methods to install Hugo on the Ubuntu 20.04 system. In fact, Hugo is an open-source static website generator written in Go language and designed for small projects and informative sites. After installation on your Linux system, you can use it to create a new static website.

Related Posts