Setting Up Hugo for Blogging on Your VPS
Setting Up Hugo for Blogging on Your VPS⌗
Introduction⌗
Now that our VPS and web server are configured, it’s time to set up Hugo—a fast and flexible static site generator. This guide walks you through installing Hugo, creating a basic blog structure, and configuring a theme that makes sense for new bloggers.
Step 1: Install Hugo⌗
Hugo provides official binaries that are more up-to-date than the versions available in Linux package managers. Below are installation methods for Linux, Windows, and macOS.
Linux Installation (Snap Package)⌗
The easiest way to install the latest version of Hugo on Linux is via Snap:
sudo snap install hugo --channel=extended --classic
Verify the installation:
hugo version
If Snap isn’t available on your system, refer to Snapcraft to install it first.
Windows Installation⌗
Download the latest Hugo extended binary from Hugo’s GitHub Releases. Extract the .zip
file and move the hugo.exe
file to a directory in your system’s PATH
, such as C:\Program Files\Hugo
.
To verify, open PowerShell and run:
hugo version
macOS Installation⌗
On macOS, the recommended way to install Hugo is via Homebrew:
brew install hugo
Alternatively, download the latest release from GitHub, extract the binary, and move it to /usr/local/bin/
.
Step 2: Create a New Hugo Site⌗
Navigate to your desired directory and generate a new Hugo site:
hugo new site myblog
cd myblog
This creates the basic structure for a Hugo site.
Step 3: Choose and Install a Theme⌗
For beginners, a clean and simple theme is best. Let’s use PaperMod
, a well-maintained and feature-rich theme.
Clone the theme into your Hugo site:
git init
git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
Enable the theme by editing hugo.toml
:
echo 'theme = "PaperMod"' >> hugo.toml
Step 4: Configure Hugo⌗
Starting from Hugo 0.110.0, the default configuration file is hugo.toml
, hugo.yaml
, or hugo.json
. While config.toml
is still supported for backward compatibility, it is considered deprecated. It’s recommended to use hugo.toml
going forward.
Modify hugo.toml
with basic settings:
title = "My Tech Blog"
baseURL = "https://yourdomain.com/"
theme = "PaperMod"
languageCode = "en-us"
[params]
author = "Your Name"
description = "A blog about Linux, VPS, and technology."
[markup]
[markup.highlight]
style = "monokai"
Step 5: Create Your First Post⌗
Generate a new post:
hugo new posts/welcome.md
Edit the file content/posts/welcome.md
and add some content. When ready, build the site:
hugo -D
Start a local preview:
hugo server -D
Visit http://localhost:1313/
to see your blog in action.
Step 6: Deploy Your Hugo Blog⌗
Once satisfied, generate the static files:
hugo
Sync the public/
directory content to your web root over SSH:
rsync -avz -e "ssh -i /path/to/private_key" public/ user@your-vps:/var/www/html/
Make sure to replace /path/to/private_key
with the correct path to your SSH private key and user@your-vps
with your VPS login details.
Your Hugo blog is now live!
Conclusion⌗
With Hugo installed and configured across Linux, Windows, and macOS, you now have a minimal, efficient blogging platform. In the next post, we’ll automate deployments with rsync and systemd timers. Stay tuned!