Hexo 文章链接默认的生成规则是::year/:month/:day/:title
一旦我们修改了时间或者文章标题,那么就会导致链接改变从而造成分享出去的页面404
解决办法是通过安装永久链接插件来解决这个问题。

安装插件

1
npm install hexo-abbrlink --save

修改全局配置文件

_config.yml修改如下:

1
2
## permalink: :year/:month/:day/:title/
permalink: posts/:abbrlink.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 s 查看效果吧!!!