教你在GitHub上搭建属于自己的博客
0.环境
VMware + Ubuntu14.03
1.安装git
$ sudo apt-get install git
2.安装node.js
$ wget https://nodejs.org/dist/v9.2.0/node-v9.2.0.tar.gz .
$ cd node-v9.2.0
$ ./configure
$ make -j4
$ sudo make install
$ node -v
v9.2.0
参考BUILDING.md
3.安装hexo
$ mkdir hexo
$ cd hexo
$ npm install hexo-cli -g
$ hexo init blog
$ cd blog
$ npm install
$ hexo generate
$ hexo server
INFO Start processing
INFO Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
INFO See you again
此时可以在Ubuntu中打开浏览器输入http://localhost:4000/或者在Windows本地打开浏览器输入http://IP地址:4000/即可看到效果。
4.登陆GitHub建仓
仓库名称格式:username/username.github.io
username是你的账号名
5.部署hexo至GitHub
首先安装deployer
$ npm install hexo-deployer-git --save
vim _config.yml 修改
deploy:
type: git
repo: git@github.com:LancerSky/LancerSky.github.io.git
branch: master
最后执行
$ hexo deploy
现在可以直接访问https://lancersky.github.io/
6.修改主题
next主题:https://github.com/iissnan/hexo-theme-next
$ mkdir themes/next
$ curl -s https://api.github.com/repos/iissnan/hexo-theme-next/releases/latest | grep tarball_url | cut -d '"' -f 4 | wget -i - -O- | tar -zx -C themes/next --strip-components=1
$ ls themes/
landscape next
vim _config.yml 修改
theme: next
$ hexo clean
$ hexo generate
$ hexo server --->可以本地查看效果