生成文章唯一链接

Hexo 的默认文章链接格式是年,月,日,标题这种格式来生成。
如果标题是中文,那 URL 链接就会包含中文。

1、安装插件,在博客根目录打开终端,运行以下指令:

1
2

npm install hexo-abbrlink --save

2、插件安装成功后,在根目录的配置文件 _config.yml 找到 permalink:
修改为

1
2
3
4
5
permalink: :abbrlink/
abbrlink:
alg: crc16 #support crc16 (default) and crc32
rep: dec #support dec (default) and hex

顶部图

配置 解释
index_img 主页的 top_img
default_top_img 默认的 top_img,当页面的 top_img 没有配置时,会显示 default_top_img
archive_img 归档页面的 top_img
tag_img tag 子页面 的 默认 top_img
tag_per_img tag 子页面的 top_img,可配置每个 tag 的 top_img
category_img category 子页面 的 默认 top_img
category_per_img category 子页面的 top_img,可配置每个 category 的 top_img

其它页面 (tags/categories/ 自建页面)和文章页的 top_img ,请到对应的 md 页面设置 front-matter 中的 top_img

tag_per_img 和 category_per_img 是 3.2.0 新增的内容,可对 tag 和 category 进行单独的配置

并不推荐为每个 tag 和每个 category 都配置不同的顶部图,因为配置太多会拖慢生成速度

1
2
3
4
5
6
7
tag_per_img:
aplayer: https://xxxxxx.png
android: ddddddd.png

category_per_img:
随想: hdhdh.png
推荐: ddjdjdjd.png
1
2
# footer 是否显示图片背景 (与 top_img 一致)
footer_bg: true

网站副标题

可设置主页中展示的网站副标题或者自己喜欢的座右铭

1
2
3
4
source: 1
# If you close the typewriter effect, the subtitle will only show the first line of sub
sub:
- 你好啊!(´◊ω◊`)

侧边栏设置

可自行决定哪个项目需要显示,可决定位置,也可以设置不显示侧边栏。
在 Aside Settings 中设置

字数统计

根目录执行

1
npm install hexo-wordcount —save or yarn add hexo-wordcount

主题配置 wordcount:

1
2
3
4
5
wordcount:
enable: true
post_wordcount: true
min2read: true
total_wordcount: true

动态标题

标签页显示 w (゚Д゚) w 不要走!再看看嘛!,回到本站显示♪(^∇^*) 欢迎回来!
在自定义 JS 中加入以下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  // 动态标题 
var OriginTitile = document.title;
var titleTime;
document.addEventListener ('visibilitychange', function () {
if (document.hidden) {
// 离开当前页面时标签显示内容
document.title = 'w (゚Д゚) w 不要走!再看看嘛!';
clearTimeout (titleTime);
}
else {
// 返回当前页面时标签显示内容
document.title = '♪(^∇^*) 欢迎回来!' + OriginTitile;
// 两秒后变回正常标题
titleTime = setTimeout (function () {
document.title = OriginTitile;
}, 2000);
}
});