title: Hexo博客生成永久链接
tags:
  - Hexo
categories:
  - Hexo
top_img: false
cover: '/upload/cdn0files/20200802133832.png'
abbrlink: b6a99401
date: 2020-08-02 13:26:12
updated: 2020-08-02 14:26:12
copyright:

先放上插件链接:hexo-abbrlink

前言

Hexo文章链接默认的生成规则是::year/:month/:day/:title,是按照年、月、日、标题来生成的。

这样的话,生成的链接非常长长长长长,而且如果我们的Markdown使用中文标题,那就更惨了,URL一转码,将是一场灾难。

更难受的是如果我们修改了文章的日期或者标题,那么将导致链接改变,别人或者你分享出去的文章就会404,这非常的蛋疼啊,所以就有了这种插件,不论你如何修改文章的日期、名称,只要不改变footer-matter中的id值,那么文章链接永远不会变。

安装插件

npm install hexo-abbrlink --save

使用

修改 _config.yml

## permalink: :year/:month/:day/:title/
permalink: posts/:abbrlink.html  ## 此处可以自己设置

增加以下配置:(还是这个yml)

## 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 cleanhexo g 哦~~~

生成的链接示意:

示例

就到这里啦,88~