前言

hexo默认提供的方案是使用年/月/日/标题,这对于seo和美观来说并不太好,当然seo无所谓我更注重于美观。我之前百度甚至谷歌搜了搜,发现并没有什么好的方法解决,只找到了一种使用id的方式,但此id非彼id,每次重新生成都会变化,及其不利于seo(主要是嫌麻烦),还有多说的thread-key也不行。

但是今天突然发现一款插件能自动生成,使用对标题+时间进行md5然后再转base64,保存在front-matter中,故有了此次记录文。

正文

安装插件

$ npm install hexo-abbrlink --save

使用方法

在站点配置文件config.yml中修改Permalink类似这样

permalink: posts/:abbrlink/

其中:abbrlink代表链接地址。

或者在config.yml文件中添加如下代码

1
2
3
4
5
# permalink: :title/
permalink: archives/:abbrlink.html
abbrlink:
alg: crc32 # 算法:crc16(default) and crc32
rep: hex # 进制:dec(default) and hex

效果展示

url/archives/e7a7798a.html

参考链接

hexo-abbrlink介绍

Github地址