Hugo Print

  • 0

How to Manually Install Hugo Static Website Generator on Ubuntu 24.04

Application: Hugo Extended
Operating System: Ubuntu 24.04 LTS
Installation Type: Manual Terminal Installation


Overview

Hugo is a fast static website generator written in Go. It allows you to create and host modern websites, documentation websites, and blogs.

This guide explains how to manually install Hugo Extended on an Ubuntu 24.04 server. The steps below perform the same actions as our automated Ansible deployment.


Requirements

  • Ubuntu 24.04 LTS server
  • SSH access to the server
  • Sudo privileges
  • Internet connection

Step 1 - Connect to Your Ubuntu Server

Connect to your server using SSH:

ssh username@server-ip-address

Example:

ssh cjmzeahj@102.202.47.171

Step 2 - Update Ubuntu Packages

First update the package list:

sudo apt update

Upgrade installed packages:

sudo apt upgrade -y

Step 3 - Install Required Packages

Install the required tools needed by Hugo:

sudo apt install -y git curl wget tar

Step 4 - Download Hugo Extended

Download the latest Hugo Extended Linux version:

cd /tmp

wget https://github.com/gohugoio/hugo/releases/latest/download/hugo_extended_linux-amd64.tar.gz

Step 5 - Extract Hugo Files

tar -xzf hugo_extended_linux-amd64.tar.gz

Confirm the Hugo binary exists:

ls -la hugo

Step 6 - Install Hugo System Wide

Copy Hugo into the system binary directory:

sudo cp hugo /usr/local/bin/

Set executable permissions:

sudo chmod +x /usr/local/bin/hugo

Step 7 - Verify Hugo Installation

Check that Hugo installed correctly:

hugo version

Example output:

hugo v0.148.2+extended linux/amd64

Step 8 - Create Website Directory

Create the directory where the Hugo website will live:

sudo mkdir -p /var/www/hugo-site

Change ownership to the web user:

sudo chown -R www-data:www-data /var/www/hugo-site

Step 9 - Create a New Hugo Website

Create a new Hugo website:

sudo -u www-data hugo new site /var/www/hugo-site

Step 10 - Create Website Content

Create the homepage content file:

sudo nano /var/www/hugo-site/content/_index.md

Add the following:

---
title: "Welcome"
---

# Hello from Hugo

This website was deployed manually on Ubuntu 24.04.

Save the file:

  • CTRL + O
  • ENTER
  • CTRL + X

Step 11 - Create Hugo Homepage Template

Create the layout directory:

sudo mkdir -p /var/www/hugo-site/layouts

Create the homepage template:

sudo nano /var/www/hugo-site/layouts/index.html

Paste:

<!DOCTYPE html>
<html>

<head>
<title>{{ .Site.Title }}</title>
</head>


<body>

<h1>{{ .Title }}</h1>

{{ .Content }}

</body>

</html>

Step 12 - Build Hugo Website

Generate the website files:

cd /var/www/hugo-site

sudo -u www-data hugo

The generated website will be created inside:

/var/www/hugo-site/public

Step 13 - Create Hugo System Service

Create a systemd service file:

sudo nano /etc/systemd/system/hugo-server.service

Add:

[Unit]
Description=Hugo Website Server
After=network.target


[Service]
Type=simple

User=www-data
Group=www-data

WorkingDirectory=/var/www/hugo-site

ExecStart=/usr/local/bin/hugo server \
--bind=0.0.0.0 \
--port=8080 \
--disableFastRender


Restart=always


[Install]
WantedBy=multi-user.target

Step 14 - Enable Hugo Service

Reload systemd:

sudo systemctl daemon-reload

Enable Hugo on startup:

sudo systemctl enable hugo-server

Start Hugo:

sudo systemctl start hugo-server

Step 15 - Check Hugo Status

sudo systemctl status hugo-server

You should see:

Active: active (running)

Step 16 - Allow Hugo Through Firewall

If UFW firewall is enabled:

sudo ufw allow 8080/tcp

Check firewall:

sudo ufw status

Step 17 - Access Hugo Website

Open your browser:

http://YOUR_SERVER_IP:8080

Example:

http://102.202.47.171:8080

Troubleshooting

Check Hugo Service Logs

sudo journalctl -u hugo-server -f

Restart Hugo

sudo systemctl restart hugo-server

Check Port 8080

sudo ss -tulpn | grep 8080

Conclusion

Hugo is now installed and running on Ubuntu 24.04. The server will automatically start Hugo after reboot.

This manual installation follows the same deployment steps used in our Ansible Hugo automation playbook.


Byla tato odpověď nápomocná?
Back