blog setup: chapter 1 Setup Steps
Build your own static blog from scratch using Hugo and NGINX. This comprehensive guide covers installation, Git configuration, NGINX setup, and generating static content—everything you need to launch your self-hosted blog on Linux.
Hugo Blog Setup Guide:
Follow this guide to learn how to setup a Hugo blog website.
It is intended to track notes and tips on how to re-build the infrastructure running this site.
Update repository index, then upgrade all packages:
sudo apt update && sudo apt upgrade -yInstall Hugo using apt:
sudo apt install hugoUse apt to install nginx
apt install nginxConfigure user’s name in git:
git config --global user.name "YOUR NAME"Configure username in git:
git config --global user.email "YOUR_EMAIL_ADDRESS"Copy the default NGINX config file into the sites-enabled folder under a custom name:
cp /etc/nginx/sites-available/default /etc/nginx/sites-enabled/SITENAMEUse hugo to create a new site:
hugo new testsiteThis will create a number of folders, one of them is the output folder: ‘public’.
Edit the site config file for Nginx:
sudo nano /etc/nginx/sites-enabled/SITENAMELook for the line that starts with ‘root’, chage it to the ‘public’ directory created by Hugo.
root /path/to/site/public/;Save and close the file.
Finally, restart the nginx service to have the changes take effect
sudo systemctl restart nginxUse the Hugo tool to generate the static content to be served:
hugo -D -v -b "https://www.domainname" --templateMetricsA brief explanation of the command above:
- -D = Build Drafts, generates output for markdown files that are in draft status
- -v = verbose output, useful for debugging issues
- -b = base url, optional?
- --templateMetrics = gather and display metrics on static content generation
A complete list of command line options can be found in the Hugo Commands Documentation