生成永久短链接优化文章插件hexo-abbrlink

一、简述

使用Hexo搭建博客已经有很长一段时间了,文章的链接也一直是使用的默认格式,文章的链接格式可以在博客根目录下的 _config.yml 文件中修改,默认的配置如下所示,最终生成的链接大概是这样的https://blog.814925.xyz/2024/10/08/这是我的第一篇博文

img

如果说文章的标题是英文,那么生成的链接还是比较简洁的,但如果是是中文的标题,就会出现裹脚布一样超级长的乱码。

二、使用 hexo-abbrlink 生成短链接

使用生成短链接的插件 hexo-abbrlink

hexo-abbrlink:https://github.com/rozbo/hexo-abbrlink

在博客根目录下,使用如下命令安装插件:

1
npm install hexo-abbrlink --save

三、使用

注意这里修改的config.yml 不是主题的config.yml 注意这里修改的config.yml 不是主题的config.yml

posts想怎么改都可以 自己喜欢

1
permalink: posts/:abbrlink.html

abbrlink配置新增# abbrlink config 放在下面

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

img

不同搭配的效果

1
2
3
4
5
6
7
8
9
10
crc16 & hex
https://post.zz173.com/posts/66c8.html

crc16 & dec
https://post.zz173.com/posts/65535.html
crc32 & hex
https://post.zz173.com/posts/8ddf18fb.html

crc32 & dec
https://post.zz173.com/posts/1690090958.html

然后三件套看一下效果,打开md文档发现abbrlink:多了一些随机数值

img

网页访问效果

img