搭建及部署
1. 安装运行环境
Node.js
git
安装最新版本即可,方法自行解决。
2. hexo 下载和安装
下载安装
1
$ npm install -g hexo-cli
设置环境变量(略)
去自定文件夹下进行初始化
1
2$ hexo init <folder> ## folder 为自定义的文件夹名,比如我的是hexo-brave
$ cd <folder>安装主题
安装next主题(本站主题)为例1
2$ cd hexo-brave
$ git clone https://github.com/iissnan/hexo-theme-next themes/next主题文件安装到themes目录下面,如下图
然后参考Next模板使用文档 进行主题配置即可。运行命令
1 | $ hexo s --debug |
生产静态文件
1
$ hexo g
发布
1
$ hexo d
部署到github
安装hexo-deployer-git程序
1 | $ npm install hexo-deployer-git --save |
配置_config.yml文件
1 | deploy: |
运行发布命令
1 | $ hexo clean && hexo deploy |
常用git命令
1 | # 拉取代码 |
问题及解决
- 提交失败的错误:解决方法:
1
2
3
4
5
6
7
8
9
10fatal: unable to access 'https://github.com/BraveChi/bravechi.github.io/': HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
FATAL {
err: Error: Spawn failed
at ChildProcess.<anonymous> (/Users/warrior/网站/github/hexo-brave/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (node:events:513:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
code: 128
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html1
2
3rm -rf .deploy_git
git config --global core.autocrlf false
hexo clean && hexo g && hexo d