Hexo + github 搭建博客
搭建Hexo博客
安装node.js
node官网下载
![](https://img.haomeiwen.com/i982286/6e2ef8c6b0a0b396.jpg)
安装git
- 使用homebrew安装
安装homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装gitbrew install git
安装hexo
sudo npm install -g hexo
新建Hexo文件夹-cd到该文件夹下
hexo init
生成静态页面
hexo generate
开启本地服务器
hexo server
![](https://img.haomeiwen.com/i982286/6f5f70de66cb3465.jpg)
打开浏览器打开该网址
![](https://img.haomeiwen.com/i982286/960b9c39335f70d5.jpg)
停止本地服务器
control + C
github上创建repository
命名方式username.github.io
安装git部署器
Could not install /Users/Karen/Hexo/ --save
进入之前创建的Hexo文件夹打开_config.yml文件
在末尾修改如下KarenRen/KarenRen修改为你的用户名
![](https://img.haomeiwen.com/i982286/619ede746b8c5772.jpg)
注意格式!!
部署
hexo deploy
输入用户名密码
![](https://img.haomeiwen.com/i982286/41a731a1c268167a.jpg)
打开https://username.github.io/
![](https://img.haomeiwen.com/i982286/14f6ab82337b72bd.jpg)
完成!!
接下来界面太丑我们来更换主题,很简单,首先将选好的主题克隆下来,更改配置文件_config.yml就可以了。
克隆到Hexo->themes文件下
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
修改配置具体见yilia博客
hexo-theme-yilia
![](https://img.haomeiwen.com/i982286/6f645f0fd20c5000.jpg)
这样配置完成后每篇文字全部显示,不够简洁,想要做成目录的样子,也就是每篇文章只显示部分怎么办。
在md文件中加入这样
以后的部分会被隐藏,点击题目,会进入到http://localhost:4000/2016/11/17/hello-world/
该文件下,也就是配置文件设置的permalink: :year/:month/:day/:title/
格式。
![](https://img.haomeiwen.com/i982286/e2ac919e7df8acd1.jpg)
如果想要添加标签例如:
![](https://img.haomeiwen.com/i982286/f99a57c06aee4fe9.jpg)
很简单,在md文件中添加如下内容即可
![](https://img.haomeiwen.com/i982286/f3979cde30635347.jpg)
![](https://img.haomeiwen.com/i982286/0fc591721c4d1cec.jpg)
常见问题汇总:
Hexo d部署的时候ERROR
提示ERROR Deployer not found: git
两种情况:
- Hexo 3.0之后deploy的type 的github需要改成git
- 可能像我一样重新init Hexo 丢失了git
总之执行npm install hexo-deployer-git --save
即可