问题描述

hexo生成文章undefined

关于hexo-abbrlink链接undefined

文章无法查看

文章全删除后hexo 三连报错

新建文件链接

此时代码为

## 启用算法生成不重复文件编号,添加
permalink: :year/:month/:day/:title/ #主题默认文章链接配置
# permalink: :year/:month/:day/:title/
#permalink: posts/:abbrlink/  # wys 是自定义的前缀 这里是为了生成的文章链接不会因为有中文而访问不到
#abbrlink:
    #alg: crc32   #算法: crc16(default) and crc32
    #rep: hex     #进制: dec(default) and hex

archive_dir: news
code_dir: downloads/code
new_post_name: :year-:month-:day-:title.md # File name of new posts
post_asset_folder: false
per_page: 0
pretty_urls:
  trailing_index: false
  trailing_html: false

当我尝试换成abbrlink之后

按照

步骤进行操作,在引入abbrlink之后就有各种报错

安装步骤按照rozbo佬引用如下

如何安装

向 Hexo 添加插件:

npm install hexo-abbrlink --save

修改 config.yml 文件中的永久链接:

permalink: posts/:abbrlink/

有两种设置:

alg -- Algorithm (currently support crc16 and crc32, which crc16 is default)
rep -- Represent (the generated link could be presented in hex or dec value)
# 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.

样本

生成的链接将如下所示:

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

新建文章后

加入后新建文章

当想要查看该文章时,显示http://localhost:4000/posts/undefined/

查看文章链接

自动定向到之前的文章

解决方法

去掉abbrlink插件或者不适用该插件(即enable改为false)

然后将根目录的_config文件 post_name处改为标题名称或者加时间加标题。