Write blog by hexo for github

Install nodejs

1
2
3
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs
$ sudo apt-get install -y build-essential

Install hexo

1
2
$ sudo npm install hexo-cli -g
$ sudo npm install hexo --save

Init Hexo blog folder

1
2
3
$ hexo init <hexo_blog_folder>
$ cd <hexo_blog_folder>
$ npm install

Install Hexo plugin

1
2
3
4
5
6
7
8
9
10
11
12
13
$ 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@0.2 --save
$ npm install hexo-renderer-stylus@0.2 --save
$ npm install hexo-generator-feed@1 --save
$ npm install hexo-generator-sitemap@1 --save

Create youre repo on github

.github.io
the name must be: your_name.github.io
enable GitHub Pages
https://github.com/your_name/your_name.github.io/settings

Init git and ssh

gen and upload public key

1
$ ssh-keygen -t rsa -b 4096 -C "<your_name>@xxx.com"

set git config

1
2
$ git config --global user.name <your_name>
$ git config --global user.email "<your_name>@xxx.com"

Custom your blog config

1
$ vim _config.yml

language: zh-CN
timezone: Asia/Shanghai
deploy:
type: git
repo: git@github.com:your_name/your_name.github.io.git
branch: master

Write new blog page

1
$ hexo new write_blog_by_hexo_2_github

Generate static blog and Deploy to remote sites

1
2
$ hexo g
$ hexo d

Hexo 命令

1
2
3
4
hexo n #生成文章,或者手动编辑
hexo s #本地发布预览效果
hexo g #生成public静态文件
hexo d #部署

本地预览效果

http://127.0.0.1:4000/

github访问

https://your_name.github.io/

Refs:

Nodejs Install
Hexo
Hexo搭建Github静态博客
简洁轻便的博客平台: Hexo详解
有哪些好看的 Hexo 主题?
使用hexo搭建静态博客
Github 搭建 Hexo 静态博客