Setup a personal blog with Hugo
I decided to create a personal blog to share my thoughts, ideas, and projects with the world. I chose Hugo as my static site generator because of its simplicity, speed, and flexibility. So, it’s a good idea to start this blog by explaining how to setup a personal blog with Hugo and deploy it on GitHub Pages.
Prerequisites
Choose a appropriate theme
Hugo has a lot of themes available on the official website. You can choose one that fits your needs and customize it to your liking. For this blog, I chose the Nightfall theme because of its clean design and simplicity.
Installation
To install Hugo, you can follow the instructions on the official website. I’m using Arch Linux, so I installed Hugo with the following command:
1
sudo pacman -S hugo
Because I choose the Nightfall theme, I need to install dart-sass, following the instructions in the Nightfall repository
1
sudo pacman -S dart-sass
Start a new site
To create a new site with Hugo, you can use the following command:
1
hugo new site personal_blog
This will create a new directory called personal_blog. Next, we need to init hugo mod to be able to use the theme
1
2
hugo mod init github.com/lchagnoleau/personal_blog
hugo mod get -u
And add the following line to the hugo.toml file:
1
2
3
[module]
[[module.imports]]
path = 'github.com/LordMathis/hugo-theme-nightfall'
To add a new post, you can use the following command:
1
hugo new content posts/my-first-post.m
Write your post in markdown format in the file content/posts/my-first-post.md and set the draft field to false to publish it.
Finally, we can start the server with the following command:
1
hugo server
Publish on Github
Create a Github repository
I push it into the .gitignore file
1
2
3
*.lock
public/
resources/
Then, create your Github repository and push your code to it
1
2
3
4
5
git init .
git add .
git commit -m "Initial commit"
git remote add origin git@github.com:lchagnoleau/lchagnoleau.git
git push -u origin master
Deploy on Github Pages
The instructions to deploy the blog on Github Pages are available here.