hexo install

1.git install

1
penn@smallasa:~$ sudo apt-get install git

2.nodejs install

1
2
penn@smallasa:~$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
penn@smallasa:~$ NVMW_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node nvm install v6.9.1

3.hexo install

1
2
3
4
5
6
penn@smallasa:~$ npm --registry=http://r.cnpmjs.org install -g hexo-cli
penn@smallasa:~$ npm --registry=http://r.cnpmjs.org install hexo-server --save
penn@smallasa:~$ npm --registry=http://r.cnpmjs.org install hexo-deployer-git --save
penn@smallasa:~$ npm --registry=http://r.cnpmjs.org install hexo-asset-image --save
or:
penn@smallasa:~$ npm install https://github.com/CodeFalling/hexo-asset-image --save

4.hexo setup

1
2
3
4
penn@smallasa:~$ hexo init blog
penn@smallasa:~$ cd blog/
penn@smallasa:~/blog$ npm install
penn@smallasa:~/blog$ npm install hexo-deployer-git --save
1
2
3
4
5
6
7
8
9
10
penn@smallasa:~/blog$ ls -1
_config.yml //Site configuration file
db.json
hs
node_modules
package.json //Application data.The EJS, Stylus and Markdown renderers are installed by default
public
scaffolds //When you create a new post, Hexo bases the new file on the scaffold.
source //This is where you put your site’s content.
themes //Hexo generates a static website by combining the site contents with the theme.

5.hexo start

1
2
3
penn@smallasa:~/blog$ hexo generate
penn@smallasa:~/blog$ hexo server -i 0.0.0.0 -p 4000
penn@smallasa:~/blog$ hexo server -s -i 0.0.0.0 -p 4000

拓展:

1
hexo server -s 启动静态模式,在静态模式中,只有public文件夹下的文件才会被放到服务器上,并且文件监听功能关闭.你可以在运行 hexo g 命令后运行该命令,通常用于生产系统中。
1
2
3
4
penn@smallasa:~/blog$ hexo new draft xixi
INFO Created: ~/blog/source/_drafts/xixi.md
penn@smallasa:~/blog$ hexo publish post xixi
INFO Published: ~/blog/source/_posts/xixi.md

1.hexo初始化

1
2
3
4
penn@smallasa:~$ hexo init blog
penn@smallasa:~$ cd blog/
penn@smallasa:~/blog$ npm install
penn@smallasa:~/blog$ npm install hexo-deployer-git --save //一定要在执行一次,否则上传git失败

2.修改_config.yaml文件

1
2
3
4
5
6
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: git@github.com:smallasa/smallasa.github.io.git
message: "{{ now('YYYY-MM-DD HH:mm:ss') }}"

3.常用命令

1
2
3
penn@smallasa:~/smallasa$ hexo clean
penn@smallasa:~/smallasa$ hexo generate
penn@smallasa:~/smallasa$ hexo deploy

4.客户端生成key

1
penn@smallasa:~$ ssh-keygen -t rsa -C "smallasa@sina.com"

5.查看公钥key,并复制

1
2
penn@smallasa:~$ cat /home/penn/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQgp76U/ftMfAAauoBC98fS9aj+/sMBMvXiqYVU4GJVukEXs9Cf5fkr9E9c39Rj2ZmBfWVftaOHbXuqT1rytH0qWXav4Qj7fIQ6B+y5M9FV6+RFClgqXBhJcg5K9rirjCzwFC2Lf60TEPTHFr/nebc8i6X6E5qSFtyOG5YYocXUKLsJp3LZZ9CF2f2JiT298/OW7kZgGdFBQ397kBc9+aCAPCCyOr9UMpU3GzMFALf3HOgQvQXncFRvSxTyEX/Er5KORqQp/Se5gDsH/QqJlcy7Fgp3GBMEUCdwrxBxcTrlKQePQn0VxSM5bFgCxGxwHH5bVddaV1DnUCaZHccZj7R smallasa@sina.com

6.登录github,切换到对应的repo(没有就创建一个新的),选择setting=>deploy keys=> add key

7.客户端设置

1
2
3
penn@smallasa:~$ git config --global user.name "penn"
penn@smallasa:~$ git config --global user.email "smallasa@sina.com"
penn@smallasa:~$ git config --global core.longpaths true

8.客户端测试

1
2
3
4
5
6
penn@smallasa:~$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.253.112)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Hi smallasa/smallasa.github.io! You've successfully authenticated, but GitHub does not provide shell access.

Error: git clone 时显示Filename too long的解决办法:

1
git config --global core.longpaths true