文章摘要
豆包AI
拼命加载中...

前言

众所周知,hexo博客的默认文章链接是::year/:month/:day/:title/(hexo配置文件的permalink),是一大坨。
然后为啥我每篇文章都要写前言?懒得写了,直接看把。

教程

安装插件

博客根目录执行:

1
npm install hexo-abbrlink --save

配置

修改_config.yml配置:

1
2
3
permalink: posts/:abbrlink/ 
pretty_urls:
trailing_html: false

1
2
3
permalink: posts/:abbrlink.html
pretty_urls:
trailing_html: true

如果想要改成其他的也没事,喜欢就好。

然后将下面的内容复制到_config.yml的最底下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# hexo-abbrlink
abbrlink:
alg: crc32 # 支持crc16和crc32算法(默认crc16)
rep: hex # 支持dec和hex值(默认dec)
drafts: false # true处理草稿,false不处理草稿。(默认false)
# 从目录树生成类别
# 深度:要生成的目录树的最大深度应大于0
auto_category:
enable: true # 默认true
depth: # 默认3
over_write: false
auto_title: false # 启用自动标题,可以按路径自动填充标题
auto_date: false # 启用自动日期,它可以自动填写日期的时间今天
force: false # 启用强制模式,在这种模式下,插件将忽略缓存,并为每个帖子计算abbrlink,即使它已经有了abbrlink

注意不是主题配置文件_config.solitude.yml

hexo三连击

1
2
3
hexo clean
hexo generate
hexo server

验证

观察在你文章的Front Matter是否多了一项abbrlink。

1
2
3
---
abbrlink: example
---

并且你的文章链接变化了。

实例

仅实例,每个人生成的都不一样。

生成的链接将呈现如下:

crc16 & hex

1
https://quicer.js.cool/posts/66c8.html

crc16 & dec

1
https://quicer.js.cool/posts/65535.html

crc32 & hex

1
https://quicer.js.cool/posts/8ddf18fb.html

crc32 & dec

1
https://quicer.js.cool/posts/1690090958.html

提醒

如果之前你已经配置了评论,并且已经有人在之前的文章链接评论过了,更新后那些评论将不能定位到新的文章链接。因此请备份好评论数据,完成上面的操作后再修改每条评论对应的url,再导入回去。