hexo 默认的链接是 permalink: :year/:month/:day/:title/ 太过于冗长,且根据标题变化

固定链接方案

hexo-abbrlink

该插件可根据文章标题和文章内容生成静态文章链接。

如何安装

1
npm install hexo-abbrlink --save

修改配置

修改 _config.yml 文件中的链接样式:

1
2
3
permalink: posts/:abbrlink/ 
# or
permalink: posts/:abbrlink.html

增加配置

1
2
3
4
5
6
7
# abbrlink config
abbrlink:
alg: crc32 # Algorithm used to calc abbrlink. Support crc16(default) and crc32
rep: hex # Representation of abbrlink in URLs. Support dec(default) and hex
drafts: false # Whether to generate abbrlink for drafts. (false in default)
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 an abbrlink. (false in default)
writeback: true # Whether to write changes to front-matters back to the actual markdown files. (true in default)

image.png

生成链接结果示例

1
2
3
4
5
crc16 & hex
https://post.zz173.com/posts/66c8.html

crc16 & dec
https://post.zz173.com/posts/65535.html
1
2
3
4
5
crc32 & hex
https://post.zz173.com/posts/8ddf18fb.html

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