开始使用
Hexo官网
Hexo是一个基于NodeJS环境的、快速、简洁且高效的博客框架。
- 能快速将MarkDown格式文件生成静态网页
- 将静态网页托管到GitPage(github提供的免费的静态网站托管服务)
- 后期个人博客维护
git安装与配置
nodejs环境安装及配置
- 下载安装
https://nodejs.org/dist/v8.1.3/node-v8.1.3-win-x64.zip
https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz
$ xz -d node-v6.10.1-linux-x64.tar.xz
$ tar -xvf node-v6.10.1-linux-x64.tar - 解压,配置PATH
1
2
3
4npm config set registry https://registry.npm.taobao.org
npm config set prefix "/u0/lixl/nodejs/node_global"
npm config set cache "/u0/lixl/nodejs/node_cache"
安装hexo及初始化
1 | -- 安装 hexo |
hexo中git配置
配置_config.yml
1 | deploy: |
推送到github
1 | npm install hexo-deployer-git@1.0.0 --save |
使用ssh redeploy
- 重新生成 SSH key
1
ssh-keygen -t rsa -C "Github的注册邮箱地址"
打开 /c/Users/user/.ssh/id_rsa.pub 并复制其内容
- 配置git
1
2
3
4
5
6
7
8
9
10
11访问 GitHub – Settings – SSH and GPG keys – New SSH key
Title: blog Key: id_rsa.pub 的内容
```
3. 修改站点配置文件 _config.yml
```yml
# 把deploy中的repo由注释的格式改为以下格式
deploy:
type: git
#repo: https://github.com/username/username.github.io.git
repo: git@github.com:username/username.github.io.git
branch: master
创建新页面
1 | hexo creat "新页面" |
添加搜索功能
1.npm安装插件
1 | npm install hexo-generator-searchdb --save |
2.修改配置_config.yml
1 | search: |
3.修改主题配置themes/next/_config.yml
1 | local_search: |
本地图片显示
1.找到Hexo下的_config.yml
1 | post_asset_folder: true |
2.安装插件hexo-asset-image
1 | npm install hexo-asset-image --save |
3.创建md文件
1 | hexo n "本地图片显示" |
生成文件 “本地图片显示.md” 和”本地图片显示”文件夹
4.md文件中添加图片
1 | {% asset_img 2019070495711.png 图片文字 %} |
5.图片放大效果
1 | $git clone https://github.com/theme-next/theme-next-fancybox3 themes/next/source/lib/fancybox |
静态资源的相对路径问题
生成的html页面部署以后js/css路径不正确?
1 | _config.yml |
添加gitalk评论
创建评论存储仓库
登录github创建一个库,用来存储评论
1.1 new repository,如https://github.com/lixl-site/blogtalk
1.2 开启issue
Settings–》Options–》Features–》Issues 勾上
申请GitHub APP key
地址 https://github.com/settings/applications/new
1 | Application name/description 任意填写,不可为空 |
主题配置
基于hexo 3.9.0/hexo-theme-next 7.2.0 版本
1 | gitalk: |
高亮主题
NexT提供了5种代码块高亮主题
1 | # Code Highlight theme |
参考chriskempson/tomorrow-theme和设置代码高亮主题
代码块复制
修改主题themes/next/_config.yml
1 | codeblock: |
设置属性copy_button为true,同时设置show_result为true,显示代码复制结果
添加mermaid支持
安装mermaid插件
npm install hexo-filter-mermaid-diagrams
启用主题支持
1
2
3
4themes\next\_config.yml
mermaid:
enable: true
甘特图
gantt title A Gantt Diagram dateFormat YYYY-MM-DD section Section A task :a1, 2014-01-01, 30d Another task :after a1 , 20d section Another Task in sec :2014-01-12 , 12d another task : 24d
序列图
sequenceDiagram Alice->>John: Hello John, how are you? loop Healthcheck John->>John: Fight against hypochondria end Note right of John: Rational thoughts! John-->>Alice: Great! John->>Bob: How about you? Bob-->>John: Jolly good!
类图
classDiagram Class01 <|-- averylongclass : cool <> Class01 Class09 --> C2 : Where am i? Class09 --* C3 Class09 --|> Class07 Class07 : equals() Class07 : Object[] elementData Class01 : size() Class01 : int chimp Class01 : int gorilla|-->
饼状图
pie title Key elements in Product X "Calcium" : 42.96 "Potassium" : 50.05 "Magnesium" : 10.01 "Iron" : 5
其他问题
1.页面导出pdf
2.关键字搜索