How To Install Hugo on Debian 12
In this tutorial, we will show you how to install Hugo on Debian 12. Hugo stands out in the static site generator landscape for its remarkable speed and flexibility. As an SEO-conscious developer, you’ll appreciate Hugo’s ability to produce lightweight, highly optimized websites that search engines love.
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 on a Debian 12 (Bookworm).
Prerequisites
- A server running one of the following operating systems: Debian 12 (Bookworm).
- 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).
- Make sure your Debian 12 system is connected to the internet. An active connection is essential for downloading the required packages and updates during the installation.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Hugo on Debian 12 Bookworm
Step 1. Before installing any software, it’s good practice to update the local package lists to ensure you have access to the latest software packages:
sudo apt update sudo apt upgrade
Step 2. Installing Hugo on Debian 12.
To install Hugo, use the APT package manager:
sudo apt install hugo
You can verify the installation by checking Hugo’s version:
hugo version
This will display the installed Hugo version, confirming that the installation was successful.
Step 3. Basic Configuration.
Now that Hugo is installed, let’s explore the basic configuration.
Creating a New Hugo Site
First, create a new Hugo site with the following command:
hugo new site test.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.
Understanding the Directory Structure
Hugo organizes your site into a clear directory structure. Familiarize yourself with the essential directories:
archetypes
: Define content templates.content
: Create your website’s content.layouts
: Customize the site’s layout.static
: Store static files like images and CSS.themes
: Install and manage themes.config.toml
: Configure your site settings.
The Significance of the Configuration File (config.toml)
The config.toml
file in your site’s root directory is where you’ll define site-wide settings. Open it with your favorite text editor to make adjustments.
Step 4. Customization and Themes.
Hugo’s flexibility extends to themes and customization:
Installing and Applying Themes
To install a Hugo theme, navigate to your site’s root directory and use the following command:
git clone <theme_repository_url> themes/<theme_name>
Replace <theme_repository_url>
with the URL of the theme’s repository and <theme_name>
with your chosen theme’s name.
Customizing the Website’s Appearance
For further customization, you can modify the layouts
and static
directories. Adjust templates and styles to match your desired website design.
Step 6. Content Management.
Hugo simplifies content creation and organization:
Creating and Managing Content with Hugo
To create new content, use the following command:
hugo new posts/my-first-post.md
This creates a new Markdown file in the ‘content
‘ directory.
Preview the site locally by running:
hugo server -D
Step 7. Accessing the Hugo Web UI.
Open your web browser and access your website using the URL http://your-server-ip-address:1313
. You should see the Hugo default page:
Congratulations! You have successfully installed Hugo. Thanks for using this tutorial to install the latest version of the Hugo on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Hugo website.