How I built this blog

Scope

This post documents the steps you can follow to build a similar blog as fast as possible and serve it locally. It focuses on getting started only.

Not covered:

Prerequisites

Setup

Install Hugo

On Fedora install Hugo from the package manager:

BASH
sudo apt update
sudo apt install hugo
Click to expand and view more

The package may be outdated (happened to me when trying to install it), in this case you can install the latest version from GitHub:

BASH
VERSION=0.154.5
wget https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_extended_${VERSION}_linux-amd64.deb
sudo dpkg -i hugo_extended_${VERSION}_linux-amd64.deb
Click to expand and view more

hugo package is available on most Linux distributions. If you’re not on Linux you may want to first install Linux (just kidding, Hugo is available for Windows and MacOS too)

Git and VS Code

Install git and VS Code :

BASH
sudo apt install git
sudo snap install --classic code
Click to expand and view more

More VS Code installation options: https://code.visualstudio.com/docs/setup/linux

Create the site

Create a new Hugo site

Create a site:

BASH
hugo new site blog --format=yaml
cd blog
git init
Click to expand and view more

Add the Hugo Narrow theme

I used the Hugo Narrow theme and its example site as a configuration reference

BASH
git submodule add https://github.com/tom2almighty/hugo-narrow.git themes/hugo-narrow
Click to expand and view more

The theme’s exampleSite/ folder contains a working configuration you can adapt.

Project configuration

VS Code recommendations

Add recommended extensions in .vscode/extensions.json to make editing Hugo projects smoother:

JSON
{
    "recommendations": [
        "gydunhn.hugo-essentials"
    ]
}
Click to expand and view more

Useful .gitignore entries

Add a .gitignore file at the root of the project to ignore generated files and OS-specific Hugo binaries:

GITIGNORE
# Generated files by Hugo
/public/
/resources/_gen/
/assets/jsconfig.json
hugo_stats.json

# Executables that might be added to repo by mistake
hugo.exe
hugo.darwin
hugo.linux

# Temporary lock file while building
/.hugo_build.lock
Click to expand and view more

Development workflow

Create your first post

Use Hugo’s new command to create a draft post:

BASH
hugo new posts/my-first-post.md
Click to expand and view more

This creates a new file under content/posts/ with front matter you can edit.

Serve the site locally

Preview your site while developing with the built-in server:

BASH
hugo serve -D
Click to expand and view more

Then visit http://localhost:1313/

Version control

Push to a remote repository

When you’re ready to track the project in Git and push to a remote git server if you have any:

BASH
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/your-username/blog.git
git branch -M main
git push -u origin main
Click to expand and view more

Next steps

Resources

Copyright Notice

Author: Dafi Dev

Link: https://dafidev.com/posts/how-i-built-this-blog/

License: CC0 1.0 Universal

This work has been marked as dedicated to the public domain.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut