插件

1
npm install hexo-abbrlink --save

功能

给文章生成永久有效的URL

原来hexo默认的文章标题格式为:

permalink: :year/:month/:day/:title/

如果title还是中文的,还有转化为URL编码,会显得更长,如果修改了year/:month/:day,可能之前分享的链接还会失效,诸多弊端,一个未使用插件的URL如下

https://2819685584.github.io/2024/09/13/Hexo%E5%B4%A9%E6%BA%83%E8%AE%B0%E5%BD%95/

修改后的样式

image-20240913231659217

应用插件

  1. 修改G:\hexo\_config.yml,修改permalink配置项

    permalink: posts/:abbrlink.html –> http://localhost:4000/post/abaf7e89.html

1
2
# permalink: :year/:month/:day/:title/
+ permalink: posts/:abbrlink.html # 此处可以自己设置,文章生成的永久链接前缀
  1. G:\hexo\_config.yml添加如下配置
1
2
3
4
# abbrlink config
abbrlink:
alg: crc32 #算法: crc16(default) and crc32
rep: hex #进制: dec(default) and hex

不同参数组合效果如下所示

  1. 还有其他参数可以设置,但是我没找到相应的中文文档和示例,先不管了,这是一个多配置的例子,但没用在我的配置文件上,仅用来学习配置参数使用

    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.
  2. hexo clean & hexo g & hexo d

GitHub项目地址

地址:hexo-abbrlink