前言

方便迁移

其实备份的时候什么都不用记录
安装的组件会记录在package.json里。

正文

变换的组件

1
2
3
4
5
6
7
npm install hexo-deployer-git --save
npm install hexo-generator-search --save
npm install hexo-generator-searchdb --save
npm install hexo-renderer-pug --save
npm install hexo-renderer-stylus --save
npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --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
2
npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save

修改了设置

_config.butterfly.yml中由

1
2
3
4
5
6
7
8
9
10
11
math:
# 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
12
math:
# 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
8
kramed:
gfm: true
pedantic: false
sanitize: false
tables: true
breaks: true
smartLists: true
smartypants: true

[blogroot]/node_modules/kramed/lib/rules/inline.js

中将

1
2
3
Line11:escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
Line20:em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
Line64:escape: replace(inline.escape)('])', '~|])')(),

注释后变为
1
2
3
escape: /^\\([`*\[\]()#$+\-.!_>])/,//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渲染为|,导致公式显示异常。
    • 方法:取消了对\|的转义。

没有改全,只是改到够用。
参考:

个性化的变化

_config.butterfly.yml中由

1
2
3
4
5
menu:
# 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
15
menu:
# 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
2
3
4
5
6
7
8
9
deploy:
- type: git
repo:
server: ssh://git@47.113.114.17:22535/home/git/repos/blog.git
branch: master
- type: git
repo:
server: ssh://git@github.com/WHUphaero/WHUphaero.github.io.git
branch: master

根据butterfly风格的文档

基于前述

1
2
npm 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
28
search:
# 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
28
search:
# 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
5
git 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
3
git add *
git commit -m "..."
git push origin master

迁移拉取

1
2
3
git clone git@github.com/{用户名}/{仓库名}.git
npm install
hexo g && hexo d

ICP

/themes/butterfly/layout/includes/footer.pug中添加了ICP备案。