How to setup a webpage
It’s not that familiar for me, who basically use c++ and python, to setup a website. So I checked some options, and decided to use Hexo.
Setting up website through Hexo is pretty simple, which I believe can be done in half an hour. Let’s begin.
My Environment:
Mac Sierra: 10.12.6
NodeJS: v8.10.0
Git: git version 2.10.1 (Apple Git-78)
Download package
First of all, the Hexo is based on two packages, NodeJS and Git. For those who don’t have/don’t know if you have these two packages, you can use the following commands on your terminal to check.
I follow the original steps of these installations.
NodeJS
1 | $ node -v |
if you don’t have NodeJS installed on you machine, you can go download it through this site.
https://nodejs.org/en/download/
Git
1 | $ git version |
if you don’t have Git installed on you machine, you can go download it through this site.
https://git-scm.com/downloads
Hexo Installation
To install hexo, we need to use node project manager to download it. I had permission error, so I use sudo to fix it.
1 | sudo npm install -g hexo-cli |
Create webpage
Create new project
After successfully install hexo, you should be able to create your own project. Here, I use “hexo_tmp” as the project name
1 | hexo init hexo_tmp |
Create new web page
Check the source_posts folder, add a markdown file, and you’re good to go.
Publish the webpage on github
Each github account can publish a webpage use github pages. The following steps would help you setup the webpage on github.
- Create github repository
- Change configuration in hexo
- Public the data to github
Create github repository
Login to you github and create a new repository like this. Notice that each account only have one free github page, and the name is restricted to “username.github.io”
The following picture is screenshot after I created the blog, so you should be okay to create a repository like this.
Change configuration in hexo
The most frequently used file in hexo should be “hexofolder/_config.yml”
You should be able to find these two parts of code in your _config.yml. Change the “username” to your account name.1
2
3
4
5# URL
url: https://username.github.io
#root:
permalink: :year/:month/:day/:title/
permalink_defaults:
1 | # Deployment |
Public the data to github
Finish above steps, you are on step to publish you website. Type the following command and you can see your website on https://username.github.io1
2
3hexo clean
hexo generate
hexo deploy