260 字
1 分钟

Hexo永久链接优化

2024-08-25
浏览量 加载中...

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

ohroy
/
hexo-abbrlink
Waiting for api.github.com...
00K
0K
0K
Waiting...

食用教程#

  1. 安装插件

    Terminal window
    #安装插件
    npm install hexo-abbrlink --save --registry=https://registry.npmmirror.com
  2. 配置链接格式

    打开 hexo根目录/_config.yml

    修改permalink为如下内容,二选一即可

    #结尾无.html
    posts/:abbrlink/
    #结尾有.html
    posts/:abbrlink.html

  3. 插件配置

    在当前配置文件中添加如下代码

    # 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.

    通过配置alg和rep参数可以改变链接大小,如下

    #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

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!

赞助
Hexo永久链接优化
https://blog.liang.one/posts/1/
作者
Liang
发布于
2024-08-25
许可协议
CC BY-NC-SA 4.0
最后更新于 2024-08-25,距今已过 534 天

部分内容可能已过时

评论区

Profile Image of the Author
Liang
数码科技爱好者
分类
标签
站点统计
文章
9
分类
3
标签
11
总字数
6,845
运行时长
0
最后活动
0 天前

目录