Hexo设置固定链接

Hexo设置固定链接

安装插件

在网站的根目录输入

1
npm install hexo-abbrlink --save

修改配置

修改网站根目录下的 _config.yml文件,找到以下内容

1
2
permalink: :year/:month/:day/:title/
permalink_defaults:

将上述两行行首添加”# ”(井号和空格)进行注释,即如下

1
2
# permalink: :year/:month/:day/:title/
# permalink_defaults:

然后在下方补充代码

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

自定义链接

编辑_posts里的md文件,找到abbrlink:,在后面填入你想使用的自定义链接即可

最后的步骤

1
hexo -g

额外的一些东西

如果想网站链接更简洁,可以将permalink: posts/:abbrlink.html改成permalink: :abbrlink.html
如本文的链接就是 blog.1213888.xyz/hexo_permalink.html