Join me LIVE now!!
If you want to generate static websites (like this blog) then Hugo is the package for you. There are several cool things about Hugo, the biggest being performance. It compiles static sites faster than any other static site generator I’ve used.
In the last tutorial, I showed how to set it up and deploy to a small Linux server, and in this article I’ll show you how to set it up for personal development in Pop!_OS. You can generate pages and push them to any static host.
The first thing you’ll need to do, if you haven’t already is install Golang
sudo apt install golang
but you’ll be a few versions behind. I like to have the freshest version of the language, so I just Download Golang and grab the latest archive for Linux. It’s a binary format so you don’t even have to build it.
Extract it with this command:
tar -C /usr/local -xzf [name of archive]
Then add the path to go in your profile:
vi ~/.profile PATH=$PATH:/usr/local/go/bin
Type in “go version” to verify:
Now you’ll need to install Hugo itself. There are a few ways to do it, including using apt, but again I like to have the latest version:
mkdir $HOME/src cd $HOME/src git clone https://github.com/gohugoio/hugo.git cd hugo go install --tags extended
This will install the latest version of Hugo to your machine. Now you’ll need to add another folder to the path so you can run hugo:
export PATH=$PATH:/home/[Your username]/go
Now you need to test out hugo:
It should look something like this:
Create a New Hugo Site
Now you’ll need to create a new Hugo site:
hugo new site hellohugo
Now you’re going to need a theme:
You can find a good list of Hugo themes here.
Once you find one you like, copy the link the repo. I choose “Hyde” for this example:
cd themes git clone https://github.com/spf13/hyde
You must then add the following to your config.toml file:
theme = "hyde"
Now create a new post:
hugo new helloworld.md
Your post should look like this:
--- title: "Post" date: 2020-03-03T22:29:45-08:00 draft: false --- Hello! This is the first blog post!
Add some content, and make sure to change “draft” to false when you’re ready to publish it.
To test it out:
And you’re ready to view your blog on localhost:1313:
All files are generated in /public so when you’re ready to publish run:
And then all the files in /public will be your new site.
Enjoy your new blog!
If you have any questions or comments feel free to contact me. Let me know what cool sites you’ve built with Hugo!
Want to learn more about Linux? Of course you do. Check out this Linux Fundamentals course. You can sign up for a free trial here and take it today!