Hugo is an open-source website framework developed in Go to help users create websites with ease. It is a reliable and modern static site generator used to create secure and extremely fast websites. Websites created using Hugo do not need a database to run and don't depend on expensive run times such as Python, Ruby, or PHP. [a]
There are three ways to install Hugo on your Ubuntu 18.04 which include:
- Using Snap
- Using apt-get
- Downloading and Installing Hugo packages.
This tutorial will show you how to install Hugo using the second (using apt-get) and third method (downloading and installing Hugo). Using Snap is not a reliable method as it presents a number of issues and requires multiple dependencies.
Step 1 - Installing Hugo
Installing Hugo Using The Apt-get Utility
The first thing when installing Hugo using the apt-get is updating your server’s apt index:
$ sudo apt-getupdate
Once the package index is updated, run the command below to install Hugo:
$ sudo apt-get install hugo
Hugo will be installed automatically on your server. To check the Hugo version installed, run the command below:
$ sudo hugo version
This will give you an output showing the Hugo version:
Hugo Static Site Generator v0.40.1 linux/amd64 BuildDate:2018-04-25T17:16:11Z
Instaling Hugo using the apt-get comes with its own advantages and disadvantages. The method is straightforward, but may not install the most recent version of Hugo. If you want to install the latest version of Hugo (v0.50, at the time of writing), use the following method.
Installing Hugo Using The dpkg utility
This method may not be as simple as using the apt utility, but it enables you to install the latest Hugo version.
First, run the command below to confirm your server architecture:
$ sudo uname -i
This will print out the specs of your server:
Now that you know your server architecture, visit the official Hugo release page to see the most recent stable release: at the time of writing this article, the latest release was Hugo v0.50.
Now, execute the following wget command to download the most recent release:
$ wget https://github.com/gohugoio/hugo/releases/download/v0.50/hugo_0.50_Linux-64bit.deb
Note: If prefer a specific version of Hugo, amend the command above to suit that particular version. For instance to download Hugo v0.25.1, run the command:
$ wget https://github.com/gohugoio/hugo/releases/download/v0.25.1/hugo_0.25.1_Linux-64bit.deb
Once the installation files are downloaded, issue the command below to extract the files and install Hugo package:
$ sudo dpkg -i hugo_0.50_Linux-64bit.deb
Next, execute the command below to delete the download package:
$ sudo rm hugo_0.30.2_Linux-64bit.deb
Then, run the command below to verify the installation:
$ sudo hugo version
This should give you an output showing the version of Hugo installed:
Hugo Static Site Generator v0.50 linux/amd64 BuildDate:2018-09-25T17:16:11Z
In case you find Hugo not useful, you can execute the command below to uninstall it:
$ sudo apt-getremove --auto-remove hugo
Step 2 - Install Hugo Themes
The Hugo themes help you present your website content in a way that appeals to your users/readers. Once you install Hugo, the next step is installing its themes. Hugo’s main package doesn't provide any theme and the best way to install Hugo themes is cloning the Hugo themes Git repository. This repository presents numerous prebuilt themes:
First, run the command below to update the package index:
$ sudo apt-getupdate
Then issue the command below to install Git:
$ sudo apt-get install git
Next, run the command below to clone this theme repository:
$ sudo git clone--recursive https://github.com/spf13/hugoThemes ~/themes
Step 3 - Using Hugo
Creating A New Website
To create a website using Hugo, first, run the command below to create a directory for the website:
$ sudo mkdir hugo-sites
Change to this directory:
Then run the command below to create the site:
hugo newsite hello-world
This will give you the output below:
Congratulations! Your new Hugo site is created in /root/hugo-sites/hello-world 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 toaddsome 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 andfull documentation.
Next, change the directory
And issue the command below:
$ sudo ls
This will give you the following output:
archetypes config.tomlcontent data layouts static themes
To preview your site issue the command below:
$ sudo hugo
This will deliver the following output:
| EN +------------------+----+ Pages | 3 Paginator pages | 0 Non-page files | 0 Static files | 0 Processed images | 0 Aliases | 0 Sitemaps | 1 Cleaned | 0 Total in 33 ms
That is it!
[a]Could you clarify what this means? Hugo is a web framework, whereas, the things you listed as having expensive runtimes are programming languages. Could you clarify this concept?