Long's Notes

Setting things up

Guide

Learning Hugo

First I need to install Hugo, and learn how to use some basic commands in order to:

Deployment

Note: ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to provide secure encrypted communications between two untrusted hosts over an insecure network. X11 connections, arbitrary TCP ports and Unix-domain sockets can also be forwarded over the secure channel.

CI/CD Pipeline with GitLab

The goal is to automatically build and deploy the site to the VPS every time a commit is pushed to main.

The pipeline has two stages defined in .gitlab-ci.yml:

The deploy only runs on main. Feature branches only run the build stage, which is enough to validate that Hugo compiles successfully.

SSH Authentication

The pipeline authenticates to the VPS using a dedicated SSH key pair:

In the pipeline, the key is loaded into an SSH agent before running rsync:

eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | ssh-add -
rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no" public/ user@vps:/var/www/public/

Nginx

Nginx is installed on the VPS and configured to serve static files from /var/www/public/:

server {
    listen 80;
    server_name _;

    root /var/www/public;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

This config is set up once manually — the pipeline only manages the file content, not the server configuration.