It`s Cool! Build my Blog Website powered by Hexo, Github Pages, deeply supported by Node.js and Git!

The building guideline is simple and clear:


1. install Node.js and Git
2. install Hexo by command line, use cygwin64 Terminal or Git Bash.

install Hexo command line tool, using hexo -v to check current version
1
$ npm install -g hexo-cli
create a local blog repo, my local blog folder is “D:/MyBlog”
1
2
3
$ cd D:
$ hexo init MyBlog
$ cd MyBlog
install node.js project manager
1
$ npm install
creat a new post, see the following examples

And there are three Layouts — post(source/_posts), page(source), draft(source/_posts)

For Chinese Blog, remember to set the Encoding as UTF-8 other than ANSI to avoid messy display,

I use Notepad++ as md file editor, pay attention to set Encoding as UTF-8 without BOM

1
2
3
4
$ hexo new page "about"
S hexo new post 新的开始 # 在source/_posts下新建一个名为“新的开始.md”的博客日志
$ hexo new page "archives"
$ hexo new page --path "Machine Learning"/"Back Propagation" # specify a folder name and post name

using NexT theme for the first theme of my blog, currently I use “hexo-theme-aero-dual” style
1
$ git clone https://github.com/theme-next/hexo-theme-next themes/next-new
copy next-new theme to /themes, revise _config.yml to set new theme style, before change theme, run ‘hexo clean’ first
1
2
3
$ hexo clean 
$ hexo generate
$ hexo server

—— then you can view your blog website in localhost:4000 ——


Excited to deploy my blog via Github Pages, firstly set up a new Github Repo for my blog website in Github, the name should be: username.github.io, where username is your Github user name, for me, it is gracecs.github.io

Install deployer command to deploy your hexo blog to Github

(Notice! You can use other deployer/server other than Git, like Heroku or Netlify, then you need to install the corresponding deployer command, see Hexo deployment for details)

1
$ npm install hexo-deployer-git --save

Change the deploy section in _config.yml, for me the root path is D:/MyBlog
1
2
3
4
deploy:
type: git
repo: https://github.com/GraceCS/gracecs.github.io
branch: master
Config your user email and username for Git account verification
1
2
$ git config --global user.email "*****@gmail.com"
$ git config --global user.name "*****"
Update your blog and deploy it to Github by:
1
$ hexo d -g

During the processing, you would be asked to enter your username of Github and your password to confirm your identity. When it shows “INFO Deploy done: git”, it means your blog site has been successfully deployed to GitHub, and anyone will be able to visit your blog now!