Hugo is a quite popular 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.
You will learn from this article how to install the Hugo website generator application on Ubuntu 20.04 system.
Hugo installation on Ubuntu 20.04
Using different ways, you can install Hugo on the Ubuntu 20.04 system. But, today we will only discuss two methods for installing Hugo:
- Install Hugo using the Ubuntu apt repository
- Install Hugo by downloading the .deb package
Method 1: Install Hugo using the apt repository
The Hugo application can be installed directly using the official Ubuntu apt repository. Open the terminal window and first update the all apt packages list. Then, install Hugo using Ubuntu apt repository by executing the below-mentioned command:
$ sudo apt update
$ sudo apt install hugo
Using the above method, you can install the Hugo application quickly on your Ubuntu 20.04 system. But, the problem with this method is that it will not install the latest Hugo application version on your system. So, this method is not recommended for Hugo installation. You can verify this method using the following command:
$ hugo --version
You will notice, the older Hugo version will be installed on your system
Method 2: Install Hugo by downloading the .deb package
Another alternative method is also available for Hugo installation on Ubuntu 20.04. The .deb Hugo package is available for download on a git repository to install the latest Hugo version. Download the latest Hugo .deb package from the git repository by running the command, which is mentioned below:
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-mentioned command:
$ hugo version
Start using Hugo on Ubuntu 20.04
As all we know is that Hugo is a new static website generator. Create a new website using Hugo. Run the below-mentioned command to create a new website using Hugo:
$ hugo new site [path_website]
$ hugo new site SampleSite
The above command will create a new folder with the name ‘SampleSite’. Navigate into it and start working in this folder. 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.
You can also create new categories and post by using the following commands:
$ hugo new [category]/[file.md]
For creating new post:
$ hugo new posts/[postname.md]
To view the whole website structure, run the below-given command:
$ hugo serve
We implemented two different methods for installing Hugo on the Ubuntu 20.04 system in this article. Furthermore, we also discussed how to create a static website using Hugo. Using Hugo, you can quickly create a new static website.
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.