How to build github page blog with hexo

My computer develop environment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ sw_vers 
ProductName: Mac OS X
ProductVersion: 10.12.6
BuildVersion: 16G29

$ brew -v
Homebrew 1.3.0
Homebrew/homebrew-core (git revision 83c2;

$ hexo -v
hexo: 3.3.7
hexo-cli: 1.0.3
os: Darwin 16.7.0 darwin x64
http_parser: 2.7.0
node: 8.4.0
v8: 6.0.286.52
uv: 1.13.1
zlib: 1.2.11
ares: 1.10.1-DEV
modules: 57
nghttp2: 1.22.0
openssl: 1.0.2l
icu: 59.1
unicode: 9.0
cldr: 31.0.1
tz: 2017b

Install hexo by npm

1
$ sudo npm install -g hexo-cli

Create your hexo project and init

1
2
3
$ mkdir hexo
$ cd hexo
$ hexo init

Install hexo plugins

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
npm install hexo-generator-index --save
npm install hexo-generator-archive --save
npm install hexo-generator-category --save
npm install hexo-generator-tag --save
npm install hexo-server --save
npm install hexo-deployer-git --save
npm install hexo-deployer-heroku --save
npm install hexo-deployer-rsync --save
npm install hexo-deployer-openshift --save
npm install hexo-renderer-marked --save
npm install hexo-renderer-stylus --save
npm install hexo-generator-feed --save
npm install hexo-generator-sitemap --save
npm install hexo-excerpt --save
npm install node-sass --save
npm install gitalk --save

Create a github New repository

  • Repository name must be the host which same with your github page domain, such as xxxx.github.io

Set your git global config

1
2
$ git config --global user.email "[email protected]"
$ git config --global user.name "your name"

Generate ssh key

1
$ ssh-keygen -t rsa -C [email protected]

Config ssh key into github

copy id_rsa.pub content to your github project ‘s Deploy keys

1
$ cat ~/.ssh/id_rsa.pub

Set your git repository url into the hexo project config

1
$ vim hexo/_config.yml
1
2
3
deploy:
type: git
repo: [email protected]:xxxx/xxxx.github.io.git

Generate static code by hexo and upload to your github page project

generate the code

1
$ hexo g

upload to github page project

1
$ hexo d

it will be public to your domain xxxx.github.io

If something went wrong

1
2
3
4
5
$ hexo new "your new post"
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Abort trap: 6

Maybe node has been updated during your blog writing ,Try to reinstall node

1
$ brew reinstall node --without-icu4c

Share