[linux学习]ubuntu下使用hexo搭建博客

1.安装Node.js

1
2
3
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

2.安装Git

1
sudo apt-get install git

3.安装hexo

1
sudo npm install hexo -g

初始你博客的根目录(或者cd到指定目录下,然后执行hexo init)

1
hexo init <dir>

4.让博客可以发布到git(参考连接:https://hexo.io/docs/deployment.html)

(1)安装hexo-deployer-git(不然会出现ERROR Deployer not found: git)

1
npm install hexo-deployer-git --save

(2) 配置你hexo博客根目录下的_config.yml文件(应该是最下面一行,修改成你的github)

1
2
3
4
5
6
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: git
repo: git@github.com:ClaymanTwinkle/ClaymanTwinkle.github.io.git
branch: master

5.hexo常用命令

1
2
3
4
5
6
7
创建页面:hexo new post "文章名字(可以是中文)"

生成html : hexo generate(或者hexo g

发布到git: hexo deploy

生成并发布:hexo generate -d (或者hexo g -d