first-post

before need

  • git
  • nginx
  • nodejs

Installation

1
$ npm install hexo-cli -g

Quick Start

Setup your blog

1
2
$ hexo init blog
$ cd blog

You can start the server

1
$ hexo server

默认端口:4000
如果需要其他端口启用,可以加-p参数,如:hexo server -p 80

Create a new post

1
$ hexo new "first install"

Generate static files

1
$ hexo generate

Install hexo-deployer-git

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

编辑_config.yml

1
2
3
4
5
deploy:
type: git
repo: git@github.com:sunlongbao/sunlongbao.github.io.git
branch: hexo
message: from hexo

这样执行hexo d会将public目录push到上面分支。

repo的名称如sunlongbao.github.io上.github.io前面部分必须与你github的username相同,这样GitHub Pages的域名会以/解析到该repo上,不会带上repo名称。

Install hexo-helper-live2d

1
2
3
4
5
6
7
$ cd /root/blog/
$ npm install hexo-helper-live2d --save
$ mkdir /root/github/ & cd /root/github/
$ git clone git@github.com:xiazeyu/live2d-widget-models.git
$ ln -s /root/github/live2d-widget-models/packages/* /root/blog/node_modules/
$ cd /root/blog/
$ hexo g -d

编辑_config.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
live2d:
enable: true
scriptFrom: local
tagMode: false
debug: false
model:
use: live2d-widget-model-wanko
display:
position: right
width: 150
height: 300
mobile:
show: true

live2d-widget-models是live2d的所有模型文件;
在hexo跟目录执行完npm会删掉node_modules/目录里面多余模块,这时候需要重新建立软连接,否则2d动画效果出不来;
hexo g -d是生成静态文件+deploy到git两个命令合并操作;

config nginx

1
$ /etc/nginx/nginx.conf

修改 /etc/nginx/nginx.conf文件,只需要将root地址改成blog的public目录即可,启动nginx,这样就能通过域名访问你的blog了。

1
2
3
4
....
server_name www.youdomain.com;
root /root/blog/public;
....