Hexo文章链接优化
灰羽 Lv3

Hexo 文章链接优化

1.建新 js 文件

主题文件夹/scripts/ 路径下,建新datelink.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"use strict";
var hexo = hexo || {};
hexo.extend.filter.register(
"before_post_render",
function (data) {
var log = this.log;
if (data.layout == "post") {
let datelink;
if (!datelink) {
var getdate = data.date;
//log.i("get date [%s]", getdate.format('YYYYMMDDhhmmss'));
data.datelink = getdate.format("YYYYMMDDhhmmss");
}
}
return data;
},
15
);

2. 修改 HEXO 配置文件

修改 hexo 的配置文件_config.yml

1
2
3
permalink: posts/:year/:month/:datelink.html
permalink_defaults:
datelink: