本Blog从默认hexo更改了哪些配置?
前言
方便迁移
其实备份的时候什么都不用记录
安装的组件会记录在package.json里。
正文
变换的组件
1 | npm install hexo-deployer-git --save |
加载的风格
1 | git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
在_config.yml中由1
theme: landscape
变为1
theme: butterfly
设置的调整
mathjax:latex的使用
基于butterfly风格的文档
依赖于前述组件的更换1
2npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save
修改了设置
在_config.butterfly.yml中由1
2
3
4
5
6
7
8
9
10
11math:
# Choose: mathjax, katex
# Leave it empty if you don't need math
use:
per_page: true
hide_scrollbar: false
mathjax:
# Enable the contextual menu
enableMenu: true
# Choose: all / ams / none, This controls whether equations are numbered and how
tags: none
变为1
2
3
4
5
6
7
8
9
10
11
12math:
# Choose: mathjax, katex
# Leave it empty if you don't need math
use: mathjax
per_page: true
hide_scrollbar: false
mathjax:
enable: true
# Enable the contextual menu
enableMenu: true
# Choose: all / ams / none, This controls whether equations are numbered and how
tags: none
在_config.yml中添加了1
2
3
4
5
6
7
8kramed:
gfm: true
pedantic: false
sanitize: false
tables: true
breaks: true
smartLists: true
smartypants: true
在[blogroot]/node_modules/kramed/lib/rules/inline.js
中将1
2
3Line11:escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
Line20:em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
Line64:escape: replace(inline.escape)('])', '~|])')(),
注释后变为1
2
3escape: /^\\([`*\[\]()#$+\-.!_>])/,//escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,//em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
escape: replace(inline.escape)('])', '~])')(),//escape: replace(inline.escape)('])', '~|])')(),
分别解决了:
- 反斜杠
\\被转义为\而非LaTeX换行- 问题描述:当公式中出现
\\表示换行时,会被kramed渲染为\,导致公式显示异常。 - 方法:取消了对
\\的转义。
- 问题描述:当公式中出现
- 下划线
_被转义为斜体而非LaTeX下标- 问题描述:当公式中出现多个下划线时,会被kramed渲染为Markdown斜体,导致公式显示异常。
- Markdown本身的语法是支持
*和_都被转义为斜体的,所以我们可以取消掉kramed对_的转义。 - 同时需要指出的是,latex中应尽量避免使用
*,而使用\ast。
- 反斜杠加竖线
\|被转义为|而非LaTeX双竖线- 问题描述:当公式中出现
\|表示紧贴符号时,会被kramed渲染为|,导致公式显示异常。 - 方法:取消了对
\|的转义。
- 问题描述:当公式中出现
没有改全,只是改到够用。
参考:
- 解决hexo-renderer-kramed渲染冲突的部分问题
- butterfly主题插入数学公式LaTeX
- 推荐hexo 更换 markdown渲染器 @upupming/hexo-renderer-markdown-it-plus,讲得很全。
个性化的变化
在_config.butterfly.yml中由1
2
3
4
5menu:
# Home: / || fas fa-home
# List||fas fa-list:
# Music: /music/ || fas fa-music
# Movie: /movies/ || fas fa-video
变为1
2
3
4
5
6
7
8
9
10
11
12
13
14
15menu:
# Home: / || fas fa-home
# List||fas fa-list:
# Music: /music/ || fas fa-music
# Movie: /movies/ || fas fa-video
首页: / || fas fa-home
时间轴: /archives/ || fas fa-archive
#遥远的回忆: /memories/ || fas fa-archive
标签: /tags/ || fas fa-tags
分类: /categories/ || fas fa-folder-open
清单||fa fa-heartbeat:
音乐: /music/ || fas fa-music
照片: /gallery/ || fas fa-images
电影: /movies/ || fas fa-video
更改了网页图标、页面背景、侧边栏和基本信息的设置等。
在/source/中保存了CNAME文件以适应Github Pages。
deploy的更改
1 | deploy: |
local-search
根据butterfly风格的文档
基于前述1
2npm install hexo-generator-search --save
npm install hexo-generator-searchdb --save
在_config.butterfly.yml中由1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28search:
# Choose: algolia_search / local_search / docsearch
# leave it empty if you don't need search
use:
placeholder:
# Algolia Search
algolia_search:
# Number of search results per page
hitsPerPage: 6
# Local Search
local_search:
# Preload the search data when the page loads.
preload: false
# Show top n results per article, show all results by setting to -1
top_n_per_article: 1
# Unescape html strings to the readable one.
unescape: false
CDN:
# Docsearch
# https://docsearch.algolia.com/
docsearch:
appId:
apiKey:
indexName:
option:
变为1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28search:
# Choose: algolia_search / local_search / docsearch
# leave it empty if you don't need search
use: local_search
placeholder:
# Algolia Search
algolia_search:
# Number of search results per page
hitsPerPage: 6
# Local Search
local_search:
# Preload the search data when the page loads.
preload: false
# Show top n results per article, show all results by setting to -1
top_n_per_article: 1
# Unescape html strings to the readable one.
unescape: false
CDN:
# Docsearch
# https://docsearch.algolia.com/
docsearch:
appId:
apiKey:
indexName:
option:
备份
坑:(来自后一个博客的提醒)注意,如果你之前克隆过theme中的主题文件,那么应该把主题文件中的.git文件夹删掉,因为git不能嵌套上传,最好是显示隐藏文件,检查一下有没有,否则上传的时候会出错,导致你的主题文件无法上传,这样你的配置在别的电脑上就用不了了。
顺便讲解一下git仓库管理命令
初始化1
2
3
4
5git init #仓库初始化
git add * #将文件加入暂存区
git commit -m "{提示词}" #将暂存区文件给一个提示词(用于标识更新时间),转入仓库
git remote add origin git@github.com/{用户名}/{仓库名}.git #存储远程仓库origin以免以后重复输
git push origin master #我只有push master分支才能成功,因为我本地git可能默认产生的是master分支
更新1
2
3git add *
git commit -m "..."
git push origin master
迁移拉取1
2
3git clone git@github.com/{用户名}/{仓库名}.git
npm install
hexo g && hexo d
ICP
在/themes/butterfly/layout/includes/footer.pug中添加了ICP备案。
