Hugo

Automatically Deploy a Hugo Site with GitLab CI/CD

Automatically Deploy a Hugo Site with GitLab CI/CD #

I wanted publishing a change to this site to be more than a reminder to log in to the server and run Hugo by hand. My GitLab pipeline connects to my Hugo server and builds the site there when I push to master.

This setup uses a self-hosted GitLab Runner that can reach the Hugo server on my home network. The pipeline does not upload a build artifact: the server has its own checkout of the blog repository, and the deploy job pulls the latest changes before running Hugo.

How to Make a New Post on Hugo

Creating New Posts in Hugo #

Hugo is a fast and flexible static site generator written in Go. Creating new posts is straightforward once you understand the basic workflow. This guide is mostly for myself since I don’t always remember how the process goes.

Step-by-Step Process #

1. Navigate to your Hugo site directory #

/var/lib/snapd/void/blog

2. Create a new post using Hugo CLI #

hugo new content content/docs/hugo-post.md

3. Edit the post content #

vim content/docs/hugo-post.md

Edit the front matter (title, date, draft status) and add your content in Markdown.