发布Hexo Blog到Github Pages
条评论文章目录
- 1. 准备环境:
- 2. 创建hexo文件夹
- 3. 安装依赖包
- 4. 本地查看
- 5. 创建页面仓库
- 6. 地址:https://github.com/这个仓库的名字需要和你的账号对应,格式: yourname.github.io问题- 生成SSH密钥1ssh-keygen -t rsa -C "你的邮箱地址"## hexo部署使用编辑_config.yml文件1234deploy: type: git repo: git@github.com:yourname/yourname.github.io.git branch: master- 配置文件的冒号“:”后面有一个空格repo: 刚刚 GitHub 创库地址.git- 部署步骤123hexo cleanhexo generatehexo deploy问题- ERROR Deployer not found: git1npm install hexo-deployer-git --save
- 7. hexo常用命令使用
- 8. 编辑文章
- 9. hexo 部署
- 10. hexo目录结构
准备环境:
安装Git
安装Node.js
安装hexo
利用npm命令安装1
npm install -g hexo-cli
问题
npm ERR! registry error parsing json 错误
可能需要设置npm代理,执行命令1
npm config set registry http://registry.npmjs.org/
hexo:command not found
删除刚刚安装的npm目录,重新执行命令1
npm install -h hexo
创建hexo文件夹
执行命令,hexo会自动在目标文件夹建立博客网站所需的所有文件
1 | hexo init |
安装依赖包
1 | npm install |
本地查看
在hexo文件夹执行以下命令,然后到浏览器输入http://localhost:4000
查看
1 | hexo generate |
问题
- WARN No layout: index.html?…
查看主题目录是否为空,如果为空下载主题1
git clone https://github.com/hexojs/hexo-theme-landscape.git themes/landscape
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {“os”:”darwin”,”arch”:”any”} (current: {“os”:”win32”,”arch”:”x64”})
官网给出的方案solution:you are both experiencing a warning that is perfectly normal and will not cause any issues for development. When using OS X there’s a nice filesystem feature provided by the OS by which file changes emit events, making “watching” files for changes the reverse, where they’re passively “listened” for (Change Detection vs an Event Emitter if you need an analogy).
This is made possible by fsevents, a package that is only available for OS X and macOS installations due to dependence on the OS’s functionality. Windows and *nix will all see this warning. I haven’t tested it, but the only non-proprietary OS that might have support would be the Darwin open source project.
所以这个警告信息可以忽略
创建页面仓库
地址:https://github.com/
这个仓库的名字需要和你的账号对应,格式: yourname.github.io
问题
- 生成SSH密钥
1
ssh-keygen -t rsa -C "你的邮箱地址"
## hexo部署使用
编辑_config.yml文件
1
2
3
4
deploy:
type: git
repo: git@github.com:yourname/yourname.github.io.git
branch: master
- 配置文件的冒号“:”后面有一个空格
repo: 刚刚 GitHub 创库地址.git
- 部署步骤
1
2
3
hexo clean
hexo generate
hexo deploy
问题
- ERROR Deployer not found: git
1
npm install hexo-deployer-git --save
1 | ssh-keygen -t rsa -C "你的邮箱地址" |
1 | deploy: |
1 | hexo clean |
1 | npm install hexo-deployer-git --save |
hexo常用命令使用
1 | hexo help |
简写
1 | hexo n == hexo new |
编辑文章
1 | hexo new "标题" |
在 _posts 目录下会生成文件标题.md:
1 | title: Hello World |
编辑完后保存,hexo server 预览
hexo 部署
1 | hexo clean |
hexo目录结构
1 | ├── .deploy |
本文标题:发布Hexo Blog到Github Pages
文章作者:xmaihh
发布时间:2018-06-22
最后更新:2018-06-22
原始链接:https://xmaihh.github.io/blog/2018/06/22/fa-bu-hexo-blog-dao-github-pages/
版权声明:采用[CC BY-NC-SA 4.0许可协议]进行许可
分享