安装
安装Nodebrew install node
该命令执行后,自动装好node和npm
安装gitbrew install git
安装hexonpm install -g hexo
创建Hexo目录
mkdir ~/Works/blog
cd ~/Works/blog
hexo init
Hexo 会自动在~/Works/blog目录下建立网站所需要的所有文件安装依赖包
npm install
本地查看
hexo generate
hexo server
到浏览器输入localhost:4000可以看到网站。注册github(已注册过了此处略)
创建 Repository
创建的时候注意Repository的名字。比如我的Github账号是zrainx,那么我应该创建的Repository的名字是:zrainx.github.io。编辑_config.yml文件
vi _config.yml
编辑并保存:1
2
3
4
5
6
7
8
9
10
11
12
13
14# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://zrainx.github.io/
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
........
........
........
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/zrainx/zrainx.github.io.git部署
hexo generate
hexo deploy
用浏览器就可以访问http://zrainx.github.io 了 :)搭建过程中遇到的问题
- 部署的时候执行:hexo deploy 命令行没有任何输出,也没有错误。
解决办法:
在部署的_config.yml文件中,找到deploy:标签,在每个冒号后面必须要空格,否则就会出现上述问题。 部署提示找不到
gitERROR Deployer not found: git
解决办法:
在Hexo 3.0版本后deploy git 被分开的,所以需要安装,安装命令如下:npm install hexo-deployer-git --save
,安装好后在尝试一下就ok部署提示email邮箱不正确
解决办法git config --global user.email "github注册邮箱"
git config --global user.name "用户名"