Introduction
Hugo is a static site generator written in Go language and it is very secure and extremely fast. It allows you to write content in a lightweight markup language like Markdown and get websites that can be published on any server.
As it is created in the Go language, the time in which the pages are built is low which makes it possible to generate large sites without any problems.
In this article, we will explain to you how to install hugo website generator on ubuntu 20.04.
Install Hugo
- Update the package index.
$ sudo apt-get update
- Using snap install the hugo latest version.
$ sudo snap install hugo
- Verify the installed version of hugo with the following command.
$ hugo version
Output
hugo v0.111.2-4164f8fef9d71f50ef3962897e319ab6219a1dad+extended linux/amd64 BuildDate=2023-03-05T12:32:20Z VendorInfo=snap:0.111.2
Create a website using hugo
- Create a new website with your own domain name using the hugo command.
For example: create a new website named$ sudo hugo new site [site-name]
test.idrivecompute.com
.$ sudo hugo new site test.idrivecompute.com
Output
- Navigate to the
test.idrivecompute.com
folder and verify the list of content installed.$ cd test.idrivecompute.com
$ ls - Initiate a repository of our website using git.
$ git init
Download and install a theme
- Install the 'graysx' theme available on hugo site, For more different themes refer to the official theme page of hugo.
$ sudo git clone https://github.com/akatiggerx04/graysx-hugo/ && mv graysx-hugo themes/graysx && cp -r themes/graysx/exampleSite/* .
- We need to edit the configuration
config.toml
file.
$ sudo nano config.toml
Save the changes and close the configuration file.baseURL = 'http://example.org/'
languageCode = 'en-us'
theme = 'graysx'
title = 'Example of Hugo Graysx Site' - Add some information to the new site by creating new content with the following command.
$ sudo hugo new posts/sample.md
- Now, let us edit the content of
sample.md
file in markdown format.
$ sudo nano content/posts/sample.md
Save your changes and close the file.---
title: "Example Title of Hugo Site"
date: 2023-03-09T09:59:32Z
draft: false
---
This is the content of an example Hugo Site page. - Start the Hugo server by specifying the instance server IPv4 address.
For example: IPv4 address: 192.168.0.1$ sudo hugo server --bind=0.0.0.0 --baseUrl=http://<your-instance-server-ip> -D -F
$ sudo hugo server --bind=0.0.0.0 --baseUrl=http://192.168.0.1 -D -F
-
Verify the installation of hugo theme by opening the browser and execute the below command.
http://192.168.0.1:1313
Output