前言

HEXO默认的文章链接格式是

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

这样子链接生成出来是https://mccsjs.eu.org/2023/01/25/galgame/qxgj/
这样的链接很长,而且改一次标题他就会改变,链接也失效了

安装插件

在博客根目录用git bash安装以下插件

1
npm install hexo-abbrlink --save

或者使用第二种
1
npm install hexo-abbrlink2 --save

安装完成后,打开博客根目录下的_config.yml,修改以下配置:

1
2
3
4
5
6
7
8
permalink: posts/:abbrlink/  # 此处可以自己设置,也可以直接使用 :abbrlink/
permalink_defaults:
abbrlink:
alg: crc32 #算法: crc16(default) and crc32
rep: hex #进制: dec(default) and hex
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks

我这种是域名/文件夹/文章的方法,例mccsjs.eu.org/posts/e7f6bd97
你也可以设置成permalink: /:abbrlink/,链接就会变成这样mccsjs.eu.org/abcd/

接下来hexo 三连即可看到成品

1
2
3
hexo cl;hexo g;hexo d
或者
hexo cl;hexo g;hexo s