喜之梁
Hexo 永久链接优化

Hexo 永久链接优化

使用 hexo-abbrlink 插件将杂乱的 Hexo 文章 URL 转换为短小精悍的永久链接,支持 CRC16/CRC32 算法与十六进制/十进制格式。

使用hexo博客时,访问文章的默认链接看起来十分杂乱,使用hexo-abbrlink插件可以完美解决这一痛点 hexo-abbrlink 插件

食用教程

  1. 安装插件 安装 hexo-abbrlink 插件的终端截图
    shell
    #安装插件
    npm install hexo-abbrlink --save  --registry=https://registry.npmmirror.com
    
  2. 配置链接格式
    打开 hexo根目录/_config.yml
    修改permalink为如下内容,二选一即可
    text
    #结尾无.html
    posts/:abbrlink/
    #结尾有.html
    posts/:abbrlink.html
    

    Hexo 配置 permalink 的截图
  3. 插件配置
    在当前配置文件中添加如下代码
    text
    # hexo-abbrlink
    abbrlink:
      alg: crc16      #支持crc16和crc32算法(默认crc16)
      rep: hex        #支持dec和hex值(默认dec)
      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.
    

    hexo-abbrlink 插件配置截图
    通过配置alg和rep参数可以改变链接大小,如下
    text
    #crc16 & hex
    https://example.com/posts/64c8.html
    # crc16 & dec
    https://example.com/posts/67535.html
    # crc32 & hex
    https://example.com/posts/8dff18eb.html
    # crc32 & dec
    https://example.com/posts/1690092958.html
    
PicList:强大的图片上传与图床管理工具
已抵达博客尽头

评论区

评论加载中...