本文转载自:https://hi-coder.gitee.io/blogs/b6a99401.html

举个粟子🌰,Hexo 默认生成的文章链接:

https://blog.wpixiu.cn/2023/04/20/Hexo生成永久链接/

转载文章的时候,这个链接因为有汉字的原因,则变成了这样:

image-20230521233534529

😡你看到这样一长串编码的时候,是不是想暴一句粗口:「啊——西巴!」。

可以看出,文章的链接里包含日期和文章标题,如果哪天修改了这篇文章的时间,则链接里的时间也会发生变化。

也就是说,🔔文章的地址发生了变化,曾经的转载链接就会失效!(默默地坑别人吧😓)

下面通过安装 hexo-abbrlink 插件,令博客链接变成永久性的,步骤如下。

1
npm install hexo-abbrlink --save

修改 _config.yaml

1
2
## permalink: :year/:month/:day/:title/
permalink: posts/:abbrlink.html ## 此处可以自己设置

修改文件_config.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
## abbrlink config
abbrlink:
alg: crc32 #support crc16(default) and crc32 进制
rep: hex #support dec(default) and hex 算法
drafts: false #(true)Process draft,(false)Do not process draft. false(default)
## Generate categories from directory-tree
## depth: the max_depth of directory-tree you want to generate, should > 0
auto_category:
enable: true #true(default)
depth: #3(default)
over_write: false
auto_title: false #enable auto title, it can auto fill the title by path
auto_date: false #enable auto date, it can auto fill the date by time today
force: false #enable force mode,in this mode, the plugin will ignore the cache, and calc the abbrlink for every post even it already had abbrlink.

一键三连,查看效果

1
hexo cl;hexo g;hexo s