GitHub Pages+Hexo 搭建个人博客
写这篇文章主要是为了记录我搭建个人博客的过程,途中经历很多困难并查询了许多资料,最终功夫不服有心人,经过一天的时间终于弄好了,废话不多说下面开搞。
一.环境搭建
安装 git
1 | $ sudo apt-get install git |
- 配置本机全局git环境
-确保已有github帐号1
2$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
下载和配置node.js
-
1
2
3
4$ tar -xvJf node-v6.10.0-linux-x64.tar.xz
$ cd node-v6.10.0-linux-x64/bin/
$ sudo ln -s node /usr/local/bin
$ sudo ln -s npm /usr/local/bin 配置环境变量
1
sudo vi /etc/profile/
-加入
1
2export PATH=$PATH:/usr/local/bin/npm
export PARH=$PATH:/usr/local/bin/node
安装hexo
初始化hexo
1
2
3
4mkdir hexo
cd hexo
sudo npm install -g hexo-cli
hexo init安装插件
1
2
3
4
5
6
7
8
9
10
11
12
13
14$ 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-util --save测试是否安装成功
1
hexo server
二.配置github
新建repository
Repository name 中填入”用户名.github.io”
如果邮箱为zhangsan@xxx.com,那么填入zhangsan.github.io勾选initialize this repository with a README
- Create repository
查看自己电脑的ssh key
1
vi .ssh/id_rsa.pub
将id_rsa.pub的内容复制到github的ssh key中
三.部署到github
修改_config.yml配置文件
1
vi hexo/_config.yml
-在最后一行加入
1
2
3
4deploy:
type: git
repository: git@github.com:用户名/用户名.github.io #用户名为自己的
branch: master部署
1
hexo g -d