什么是 hexo
hexo 是一个快速、简洁且高效的博客框架
配置环境
- 安装node
- 安装git
- 申请github账号
安装hexo
1 | $ npm install -g hexo |
新建一个文件夹,如hexo
初始化
1 | $ hexo init |
生成静态页面
1 | $ hexo g(或hexo generate) |
本地启动
1 | $ hexo s(或 hexo server) |
然后在浏览器输入localhost:4000 就可以看到属于默认博客
新建博客
1 | $ hexo new 'my-first-blog' |
修改主题
1 | git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia |
修改_config.yml中的theme: landscape改为theme: yilia,然后重新执行hexo g来重新生成
主题参考链接
配置github
- 建立仓库(注:在github建立的仓库,仓库名一定为“username.github.io”,这是固定写法)
- 配置SSH key
- 测试是否成功:ssh -T git@github.com
看到这个信息说明SSH已配置成功:Hi XXX! You’ve successfully authenticated, but GitHub does not provide shell access. - 打开根目录下的_config.yml
1
2
3
4deploy:
type: git
repository: https://github.com/username/username.github.io.git
branch: master - 使用git部署
1
npm install hexo-deployer-git --save
部署三部曲
- hexo clean
- hexo g
- hexo d