Hexo的默认URL格式是日期加标题,permalink: :year/:month/:day/:title/,这种格式有很多缺点:

  • 缺点一:url过长
  • 缺点二:年月日都有分隔符,url层级过多
  • 缺点三:如果标题是中文,url会自动被编码,就会造成所谓的乱码现象,导致url过长

不好看也不利于seo

hexo-abbrlink插件

  • 进入Hexo博客根目录,安装插件

    1
    npm install hexo-abbrlink --save
  • 修改hexo的配置文件_config.yml中的permalink

    1
    permalink: article/:abbrlink/
  • 在下面加上image-20200708153957307

    1
    2
    3
    4
    5
    6
    7
    8
    9
    abbrlink:
    alg: crc16 #support crc16(default) and crc32
    rep: hex #support dec(default) and hex
    drafts: false #(true)Process draft,(false)Do not process draft
    # Generate categories from directory-tree
    # depth: the max_depth of directory-tree you want to generate, should > 0
    auto_category:
    enable: false
    depth:
  • alg&rep的配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    crc16 & hex
    https://post.zz173.com/posts/66c8.html

    crc16 & dec
    https://post.zz173.com/posts/65535.html
    crc32 & hex
    https://post.zz173.com/posts/8ddf18fb.html

    crc32 & dec
    https://post.zz173.com/posts/1690090958.html
  • 局限性:crc16的最大帖子数是65535,但是对于大部分人也够用了

最后链接就是这样的image-20200708155035354

评论