WHY: Why do I want to construct my blog site?
- Contributing to and being involved in the open-source community
- Sharing some knowledge with my own understanding way and logic
- I am a tech-geek who loves to learn some new tech
- Increasing my popularity to make more people know about me and accept my ideal.
WHAT
What is the Blog Site
- A unique site that runs your blog, people could directly gain access to your blog through website address or searching engines
- A place that you could post your own idea, share your thinking, help others, and introduce yourself
What is the difference between constructing own site and use others services of other companies? (WHY I do not want to use other companies service directly?)
- More freedom in configuring your webpage, customizing your appearance, and fewer limitations from companies
- Cheaper price (even no price) running the whole service (you could choose every service you want)
- Less worry of your posts will be deleted or modified by the services’ runner
- You will learn more things about constructing a blog, like
hugousage, IP allocating, etc. - The site constructed by your own is more appealing to geeks, companies, and educational facilities which means you would gain more opportunities from them.
HOW
Basic Constructing
Pre-request
- A valid GitHub account
- Already installing
Hugoon your machine:$ sudo pacman -S hugo
Create a new GitHub Page
- Create a new repo with Repository name
YOUR_GITHUB_NAME.github.io, then your repo will look like this:YOUR_GITHUB_NAME/YOUR_GITHUB_NAME.github.io, e.g. Mine iszayn7lie/zayn7lie.github.io - Connect the repo to your local computer
- You could use
HTTPSmethod withGitHub authorizationorSSH, I will show how to connect withHTTPSmethod - Record your repo’s
HTTPS, e.g.https://github.com/zayn7lie/zayn7lie.github.io.git $ git clone YOUR_HTTPSto clone the repo to local orgit init .thengit remote add origin YOUR_HTTPS
- You could use
- In the repo, turn to
Setting-Code and automation-Pages, checkBuild and deployment-SourceisDeploy from a branch, andBranchismaster
Setting up source code for blog
- Turn to your local machine,
$ hugo new site YOUR_SITE_NAMEto create and initial your new blog site, addYOUR_GITHUB_NAME.github.ioinbaseURLin./hugo.toml - Turn to the folder you just connect with your
GitHub Page, rename it aspublicwith moving it to your site folder you just have generated. $ hugo new content posts/my-first-post.mdto generate a new post for your blog (Remember to useMarkdownto write)- After writing, removing header
draft: trueto make it visible,$ hugo serverto view your pre-generate blog, you can see it in http://localhost:1313/.Read Moreif you encounter problems. - After checking,
$ hugoto generate the finalhtmltopublicfolder, then commit it to yourGitHubrepo. GitHubwill automatically runActionto build your blog website withJekyll(you do not need to know anything aboutJekyll), after compiling, you could see your public website inYOUR_GITHUB_NAME.github.io
Advanced Configuration
The global config file is in
./hugo.toml
Theme Setting
I am using Stack, it has a doc for fully configuration that you could read.
- Create a
themesfolder, and move the theme folder that you want to adopt, tothemesfolder. - Open
hugo.toml, inserttheme = "YOUR_THEME_NAME"at the beginning - If you want to do modification with your theme, you just need to copy the specific file from your theme folder to the root file, then modify it. E.g. I want to modify
themes/hugo-theme-stack/layouts/_default/baseof.html, I could just create alayouts/_default/baseof.htmlin root and modify it. - More things could be modified in
hugo.toml, I just show mystack themeconfig:[param](Erasing some sensitive information):
[params]
mainSections = [ "posts" ]
favicon = "/favicon.png"
[params.dateFormat]
published = "01/02/2006"
lastUpdated = "01/02/2006"
[params.sidebar]
compact = false
subtitle = "Algorithm&Mathematics, Music_Theory&Rhythm_Game, Rationality&Logicism, Peace&Open_Source"
[params.article]
math = true
[params.article.license]
enabled = true
default = "Licensed under [CC BY 4.0](https://zayn7lie.ber7.org/posts/misc/license/)"
[params.comments]
enabled = true
provider = "cusdis"
[params.comments.cusdis]
host = "https://cusdis.com"
id = "SENSITIVE_INFORMATION"
[params.widgets]
homepage = [
{type = "search"},
{type = "categories", params = {limit = 77}},
{type = "tag-cloud", params = {limit = 77}}
]
page = [
{type = "toc"},
{type = "tag-cloud", params = {limit = 10}},
{type = "archives", params = {limit = 10}}
]