DebianLinuxTutorials

How To Install Hugo on Debian 11

Install Hugo on Debian 11

In this tutorial, we will show you how to install Hugo on Debian 11. For those of you who didn’t know, Hugo is a free and open-source website framework written in developed in Go. Hugo provides a reliable and modern static site generator. It is capable of generating a site at a speed of less than 1 ms per page. It works by shipping pre-made templates to make a quick work of SEO, analytics, commenting e.t.c. Hugo sites can run without any expensive run times like PHP, Python, or Ruby and don’t need any database.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Hugo static site generator on a Debian 11 (Bullseye).

Prerequisites

  • A server running one of the following operating systems: Debian 11 (Bullseye).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Hugo on Debian 11 Bullseye

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade

Step 2. Installing Hugo on Debian 11.

By default, Hugo is available on Debian 11 base repository. Now we install Hugo using the following command to your Debian system:

sudo apt install hugo

Verify Hugo installation using the which command:

hugo version

Step 3. Create a Website Using Hugo on Debian 11.

Now set to start creating website content. First, you will need to create a new website let’s name it hugo.idroot.us so that our command will look as such:

hugo new site hugo.idroot.us

Output:

Congratulations! Your new Hugo site is created in /root/hugo.idroot.us.

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 " command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new /.".
3. Start the built-in live server via "hugo server".

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

List all the created files under the website:

ls -l hugo.idroot.us

Output:

drwxr-xr-x 2 root root 4096 Nov 17 09:46 archetypes
-rw-r--r-- 1 root root   82 Nov 17 09:46 config.toml
drwxr-xr-x 2 root root 4096 Nov 17 09:46 content
drwxr-xr-x 2 root root 4096 Nov 17 09:46 data
drwxr-xr-x 2 root root 4096 Nov 17 09:46 layouts
drwxr-xr-x 2 root root 4096 Nov 17 09:46 static
drwxr-xr-x 2 root root 4096 Nov 17 09:46 themes

Step 4. Create an About page and Sample Blog Post.

First, change the directory to your website using the following command below:

cd hugo.idroot.us
hugo new about.md

Output:

/root/hugo.idroot.us/content/about.md created

We need to add some content to the about file:

nano content/about.md

Change the file as shown below:

---
title: "About Us"
date: 2021-11-17T09:46:18Z
draft: false
---

This is About Us page for this website.

Next, create a sample post using the following command below:

hugo new post/page.md

Output:

/root/hugo.idroot.us/content/post/page.md created

Open the created file and add some content to it:

nano content/post/page.md

Change the file as shown below:

---
title: "Page"
date: 2021-11-17T09:46:29Z
draft: true
---

# Hugo Page

This is my first hugo website page!

Now, you will need to build your website to use it. You can build it by running the following command below:

hugo

Output:

{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}

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

Total in 46 ms

With the website built, start your Hugo server and bind it to your server IP address as below:

hugo server --bind=0.0.0.0 --baseUrl=http://192.168.77.21 -D -F

Step 5. Accessing the Hugo Website.

Once successfully installed, open your web browser and access your website using the URL http://your-server-ip-address:1313. You should see the Hugo default page:

Install Hugo on Debian 11 Bullseye

Congratulations! You have successfully installed Hugo. Thanks for using this tutorial for installing the latest version of the Hugo static site generator on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official Hugo website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button