Hexo生成永久链接Html

Hexo的默认生成规则介绍

在config.yml中,默认的路径生成规则为::year/:month/:day/:title,是按照年、月、日、标题来生成的。生成的链接非常长,如果标题中含中文的话,复制URL链接会转一大串编码字符。

此插件,不论你如何修改文章的日期、名称,只要不改变 footer-matter 中的 id 值,那么文章链接永远不会变。

安装步骤

  1. 执行下面命令
    1
    2
    3

    npm install hexo-abbrlink --save

  2. 修改config.yml
    1
    2
    3
    4
    ## permalink: :year/:month/:day/:title/
    permalink: posts/:abbrlink/
    ## or
    permalink: posts/:abbrlink.html
  3. 增加以下配置(查看永久链接生成规则,可以进行适当调整 alg/rep)
    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.
  4. 三连查看效果即可

    1
    2
    3
    hexo clean
    hexo g
    hexo s

其他配置意义可查看插件文档,链接如下

hexo-abbrlink