Hexo博客生成永久URL
插件
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/
修改后的样式
应用插件
修改
G:\hexo\_config.yml,修改permalink配置项permalink: posts/:abbrlink.html –> http://localhost:4000/post/abaf7e89.html
1 | # permalink: :year/:month/:day/:title/ |
- 在
G:\hexo\_config.yml添加如下配置
1 | # abbrlink config |
不同参数组合效果如下所示
- crc16 & hex –> https://post.zz173.com/posts/66c8.html
- crc16 & dec –> https://post.zz173.com/posts/65535.html
- crc32 & hex —> https://post.zz173.com/posts/8ddf18fb.html (当前使用)
- crc32 & dec —> https://post.zz173.com/posts/1690090958.html
还有其他参数可以设置,但是我没找到相应的中文文档和示例,先不管了,这是一个多配置的例子,但没用在我的配置文件上,仅用来学习配置参数使用
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.hexo clean & hexo g & hexo d




