GitHub搭建博客
安装node.js
安装完成后测试
1 2 3 4
| npm -v # 6.4.1 node -v # v10.14.2
|
安装hexo
全局安装hexo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| npm install hexo -g
# 安装完查看 hexo -v # 输出 hexo-cli: 1.1.0 os: Windows_NT 10.0.17763 win32 x64 http_parser: 2.8.0 node: 10.14.2 v8: 6.8.275.32-node.45 uv: 1.23.2 zlib: 1.2.11 ares: 1.15.0 modules: 64 nghttp2: 1.34.0 napi: 3 openssl: 1.1.0j icu: 62.1 unicode: 11.0 cldr: 33.1 tz: 2018e
|
GitHub创建项目,并拉至本地
注意:项目名格式必须为 用户名.github.io
初始化hexo环境
1 2 3 4 5 6
| # 新建blog目录,在目录下执行命令 hexo init # 完成后安装依赖 npm install # npm install hexo-deployer-git --save
|
配置ssh,让本地可免密push到GitHub
略
新建博客,并上传到git
新建博客
配置
1 2 3 4 5
| # 在_config.yml最后配置 deploy: type: git repo: git地址 branch: master
|
部署
增加搜索功能
安装插件:
1
| npm install hexo-generator-searchdb --save
|
修改配置文件
1 2 3 4 5 6 7 8 9
| search: path: search.xml field: post format: html limit: 10000
local_search: enable: true
|
安装mermaid插件:
安装命令
1
| npm install hexo-filter-mermaid-diagrams -u
|
配置
_config.yml中增加配置:
1 2 3 4 5 6
| mermaid: enable: true version: "7.1.2" options:
|
在页面加入引用:github地址
1 2 3 4 5 6 7 8
| <% if (theme.mermaid.enable) { %> <script src='https://unpkg.com/mermaid@<%= theme.mermaid.version %>/dist/mermaid.min.js'></script> <script> if (window.mermaid) { mermaid.initialize({theme: 'forest'}); } </script> <% } %>
|
报错
- ERROR Deployer not found: git
1
| npm install --save hexo-deployer-git
|