为什么要优化

Hexo默认的文章永久链接格式是:

1
year/:month/:day/:title/

这种格式遇到中文标题,很是不好,而且分享文章时,由于编码问题,会使得文章链接变成好长一串子,看着难受。

abbrlink插件能很好的给我们解决这个问题。

插件Github地址为:https://github.com/rozbo/hexo-abbrlink

如何优化

1.安装abbrlink 插件

在博客根目录下打开命令行。输入以下命令安装插件:

1
npm install hexo-abbrlink --save

2.配置config.yml 文件

1
2
3
4
5
6
#permalink: :year/:month/:day/:title/
#permalink_defaults:
permalink: posts/:abbrlink/
abbrlink:
alg: crc32 #support crc16(default) and crc32
rep: dec #support dec(default) and hex

一定要注意把之前的permalink: :year/:month/:day/:title/ 给注释掉,否者会报错。

1
2
3
4
5
#算法(目前支持crc16和crc32,默认为crc16)
alg -- Algorithm (currently support crc16 and crc32, which crc16 is default)

# 表示(生成的链接可以以十六进制或十进制值表示)
rep -- Represent (the generated link could be presented in hex or dec value)

效果图

image-20220427152221327

参考链接:https://blog.csdn.net/Mculover666/article/details/103137719