这一篇我们来讲解如何使用 hexo 和 github 搭建个人博客。
条件:
- 基于node
- npm包管理工具
下载 hexo
npm install hexo-cli -g
// 如果使用淘宝镜像的话
npm install hexo-cli -g --registry=https://registry.npm.taobao.org
在一个空目录下执行博客系统的初始化
hexo init
hexo\source_posts md文档就是博客文档
如果要写一篇博客,新建文件 xxx.md
把md文档转html文件
hexo g
在自己的服务器预览 localhost:4000
hexo s
重新生成html文件可能会有缓存
hexo clean,hexo g
如果要和github关联 推代码到github,则需要hexo-deploy-git 插件
npm install hexo-deployer-git --save
接下来需要配置文件,修改文件 _config.yml 在最下面
type: git
repo: git@github.com:用户名/用户名.github.io.git
branch: master
需要在github配置仓库 名称(用户名.github.io)
把代码推到github
hexo d
配置当前仓库可以通过网络访问页面
在仓库的首页 settings—>GitHub Pages–>改选项 Source(none—master branch)
通过 用户名.github.io 访问你的博客
see you ~