hexo 创建博客部署到github上

1,准备环境

首先打开github,点击New repository,创建一个新仓库,仓库名必须要遵守格式:账户名.github.io,不然接下来会有很多麻烦。并且需要勾选Initialize this repository with a README。

2,安装hexo

1
2
3
4
5
6
7
8
npm install hexo -g --registry=https://registry.npm.taobao.org
mkdir hexo
cd hexo
hexo init
hexo install --registry=https://registry.npm.taobao.org

#安装部署到github的插件
npm install hexo-deployer-git --save

3, 部署到github

1
2
3
4
5
6
#生成静态文件
hexo g
#启动服务,可以在浏览器中查看
hexo s
#部署到github中
hexo g && hexo d

4,创建自定义域名

1
2
3
4
5
6
cd source/
#在source目录下创建自定义域名文件CNAME,直接输入youdomain.com
vi CNAME
#保存域名
#自定义域名部署到gihtub
hexo g && hexo d

5,发布文章

1
2
hexo new post test
hexo clean && hexo g && hexo d