Hugo Quickstart
2020-12-01
Here is a quick tutorial on how to get started with Hugo, the super fast framework for building websites. (Although this website is built with Zola...)
I'm glad if this post could help someone get started with it too!
There will be two parts:
1. Quickstart
2. Deploying to GitHub Pages
1. Quickstart
I assume that you already have hugo installed on your machine, so I'll skip that part.
-
hugo new site quickstart
to generate a hugo website. You can replacequickstart
with whatever name you like. -
cd quickstart
to go to the folder you just created. -
git init
to initialize a git repo. -
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke
to install a theme you like. In this example, we are installingananke
theme. -
echo 'theme = "ananke"' >> config.toml
to use the theme. Or open the folder in your favorite text editor, open the config.toml file, and writetheme = "ananke"
. -
hugo new posts/my-first-post.md
to create a new post. -
my-first-post.md
should look like the following.--- title: "My First Post" date: 2019-03-26T08:47:11+01:00 draft: true ---
Sometimes, it's
+++
instead of---
, so you might have to modify that manually. -
Write anything you want in
my-first-post.md
and that's pretty much it for the first part! -
hugo server -D
orhugo server -t <your-theme>
(if you use a theme) to see what your website looks like.
2. Deploying to GitHub Pages
I assume that you already have a GitHub account.
-
Create a new repository
<your-blog>
. -
Create another repository, but this time the name should be
<your-user-name>.github.io
. -
git clone <your-blog>
orgit remote add origin <url-to-your-blog-repo>
to skip step 4. -
Move all the files and folders in your
quickstart
into<your-blog>
repo. -
Make sure your website works locally by running
hugo server
orhugo server -t <your-theme>
. -
git submodule add -b master https://github.com/<your-user-name>/<your-user-name>.github.io.git public
to create a git submodule. -
Run
hugo
orhugo -t <your-theme>
(if you use a theme). This should create a public folder in your working directory. -
cd public
and all that's left to do is togit add
,git commit
, andgit push
it.
git add .
git commit -m "Your comment."
git push -u origin master
- Now go to
https://<your-user-name>.github.io
, and you should see your website running!