Introduction and Overview
Building a generic website from scratch is a tough work. However, personal websites for blogs, a special type of website, is actually programmatic. Hugo provides a convenient building templates for that. To make a new blog in Hugo, one could only just create a new folder, write a markdown file (in a specific format) and that’s it. You don’t need ANY knowledge about HTML or CSS. Well do you need to buy a domain name for everyone to see your posts? Well, GitHub Pages is a free service where you just push some contents in a repository of your own with some extremely easy command line, you created your sites of names like yourname.github.io
.
Tools needed
Homebrew (Packet Manager)
We will use a packet manager called Homebrew to install Hugo. Follow the commands here to download Homebrew first, or you can execute:
|
|
Once downloaded, if you don’t get any error by entering this in the terminal in any folder, you installed it properly (Install testing):
|
|
Git (Version Control System)
You can use Homebrew to install Git:
|
|
Install Hugo
Run this in any folder:
|
|
Install testing:
|
|
Run Example Theme
Create Framework
Enter the terminal in any folder, you will be creating another main folder called mysite
in it. Folder mysite
will contain all the contents that are relevant to your website:
|
|
Folder mysite
should look like this:
with most folders in it empty. This is the framework.
Choose Theme
The themes
folder is empty, now we will add some code representing a theme inside it. Now choose a template here and downlaod its source code folder inside the themes
folder. I use Stack
|
|
Run Theme
Now there should be a folder inside themes
. Now copy all the things inside a folder like exampleSite
into the main mysite
folder (‘‘replace’’).
Go to the main mysite
folder and remove the original hugo.tomal
file, or you can do:
|
|
Then (in mysite
folder), run:
|
|
it will prompt something like:
|
|
Enter the link provided (http://localhost:53844/
). You are done!
Play Around
This is easy, just compare the contents in each folder and the website and modify things a little.
Publish your website
Note the link (http://localhost:53844/
) is private and cannot be visited on other devices. So follow these steps to publish it:
Create GitHub Repository
Go to your GitHub page and click ‘+’ on the right upper corner, choose New repository
and name it like this:
i.e., yourname.github.io
, which will be your own domain name.
Push Contents
Run this:
|
|
Then push the contents in your folder public
on it by:
|
|
You can access your website on https://yourname.github.io/
within several minutes.
Notes
After you change contents locally, the contents on https://yourname.github.io/
will not change automatically, you will have to push it on GitHub again:
|
|
Also the public website will not update instantly, you will have to wait several minutes.