🌐 How to Build a Static Website with Hugo in Under Ten Minutes: A Step-by-Step Guide
Discover how to showcase your work using Hugo, a powerful tool that integrates markdown files with a CI/CD pipeline, minimizing the time needed to build a professional-looking website.
🎯 Project Objectives
- Learn how to build a Hugo website in under five steps.
- Understand the process of setting up a CI/CD pipeline in just another two minutes.
Necessary Tools
homebrew; installation instructions can be found here.- A Hugo theme; you can choose from a wide variety here. For this tutorial, we’ll use the
papertheme from nanxiaobei, which embodies simplicity and minimalism.
🏗️ Basic Hugo Setup Procedure
- Install
hugo.
brew install hugo
- Create a
hugowebsite.
hugo new site your-username.github.io -f yml
Notes
- I prefer using the
ymlconfigs because it gets automatically linted within VS Code. - Using
your-username.github.ioallows you to use that as the URL when it gets published to the web.
- Install your theme
# Jump into directory
cd your-username.github.io
# Add theme as a submodule
git init
git submodule add https://github.com/nanxiaobei/hugo-paper themes/paper
- Update your
yamlconfig.hugo.yamlconfig
languageCode: en-us
baseURL: your-username.github.io
title:
theme: paper
- Create a new post
hugo new posts/<new_post_name>
Your directory should look something like the below but if not, change the hugo.toml to hugo.yaml.
├── archetypes
│ └── default.md
├── assets
├── content
│ └── posts
│ └── build-static-website-hugo-10-minutes.md
├── data
├── hugo.yaml
├── layouts
├── resources
│ └── _gen
│ ├── assets
│ └── images
├── static
└── themes
└── paper
...
- Run
hugo server -Dto render the website (it should be hosted onlocalhost:1313). You should have something that looks like this:
Plain blog built with Hugo
⚙️ Configuration
There are parameters available to use within the params of the hugo.yaml. They can be found here.
➕ Adding a new page
- Adding a new page is simple as, for example using
content/projectswill create a newmarkdownfile calledprojects.mdwithin the foldercontentas per the template found within thearchetypes/default.mdfile.
Editing the projects.md will reflect the changes within the browser upon saving.
# hugo new <folder_name>/<post_name>
hugo new content/projects
🔄 Implementing CI/CD with Github Actions
To take this another level further, you can automate the update of your website using the following Github actions file.
- Refer to this CI/CD pipeline guide from
Hugo.
- Copy the
hugo.yamlfile fromStep 6. - Run a
git push - Your website should now be live.
Inception…