这是利用hexo在GitHub上建立自己的博客的流程,记录下方便查询。
起步
基于node npm包管理工具安装 hexo
1
| $ npm install -g hexo(hexo-cli)
|
如果外网资源较慢,可以使用淘宝镜像(代理的仓库)
1
| $ npm install -g hexo --registry=https://registry.npm.taobao.org
|
在一个空目录中初始化博客系统
目录hexo\source_posts下的md文档就是博客文档,添加博文将新建的xxx.md文件放到这里即可。
把md文档转html文件
在自己的服务器预览, localhost:4000
如果从新生成html文件可能会有缓存,那就先clean一下,在执行 hexo g
和GitHub关联,推送代码到github上
安装hexo-deploy-git 插件
1
| $ npm install hexo-deployer-git --save
|
修改配置文件 _config.yml
1 2 3
| type: git repo: git@github.com:用户名/用户名.github.io.git branch: master
|
在GitHub配置仓库名称(你的用户名.github.io)
推送代码到GitHub
到这一步,只能预览代码,不能预览页面,还需要配置当前仓库可以通过网络访问页面
- 在仓库的首页 settings—>GitHub Pages–>改选项 Source(none—master branch)
- 通过 用户名.github.io 访问你的博客