博客文章链接优化之abbrlink

前言
原文链接:HEXO | 博客文章链接优化之ABBRLINK
hexo的默认永久链接是在_config.yml里的配置permalink: :year/:month/:day/:title/。这种默认配置有个很不能接受的缺点,文件名为中文,会导致url链接里面出现中文。这次我来介绍一个比较方便好用的解决方案hexo-abbrlink插件。

安装hexo-abbrlink插件

1
npm install hexo-abbrlink --save

然后在 Hexo的根目录的配置文件_config.yml 中修改:

站点配置文件(_config.yml)里:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
permalink: post/:abbrlink.html
## abbrlink配置
abbrlink:
alg: crc32 #support crc16(default) and crc32 进制
rep: hex #support dec(default) and hex 算法
drafts: false #(true)处理过程,(false)不处理过程。false(缺省值)
## 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 g 会自动在你的文章中加上abbrlink: fbf5310d