Hexo使用abbrlink插件生成文章固定编号链接

Hexo生成的静态链接默认生成规则『:year/:month/:day/:title』,这个规则在修改文章标题后链接也会改变,不利于分享给别人,本文将利用『hexo-abbrlink』插件将文章生成固定链接

插件1:hexo-abbrlink

该插件生成的固定链接为随机形式,官网:https://github.com/rozbo/hexo-abbrlink

安装

1
npm install hexo-abbrlink --save

配置

打开config.yml文件,修改permalink的值

1
2
3
4
# 形式1
permalink: posts/:abbrlink/
# 形式2
permalink: posts/:abbrlink.html

添加如下内容,其中:alg为链接的生成算法,可选crc16和crc32;rep为生成的链接形式,可选hex和dec

1
2
3
abbrlink:
alg: crc32
rep: hex

样例

  • crc16 & hex:…/posts/66c8.html
  • crc16 & dec:…/posts/65535.html
  • crc32 & hex:…/posts/8ddf18fb.html
  • crc32 & dec:…/posts/1690090958.html

插件2:hexo-abbrlink2

该插件生成的固定链接为有序增长的形式,官网:https://github.com/rozbo/hexo-abbrlink2

安装

1
npm install hexo-abbrlink2 --save

配置

打开config.yml文件,修改permalink的值

1
2
3
4
# 形式
permalink: posts/:abbrlink/
# 形式2
permalink: posts/:abbrlink.html

添加如下内容,其中:start为起始id

1
2
abbrlink:
start: 1000

样例

  • 链接1:…/posts/1000.html
  • 链接2:…/posts/1001.html
  • 链接3:…/posts/1002.html
  • 链接4:…/posts/1003.html