侧边栏壁纸
博主头像
TLSOU-特来搜分享 博主等级

特来搜,全网优质资源分享......

  • 累计撰写 31 篇文章
  • 累计创建 51 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

hexo生成html永久链接

特来搜
2025-03-04 / 0 评论 / 0 点赞 / 20 阅读 / 0 字 / 正在检测是否收录...

hexo生成html永久链接

一、使用

1.Hexo_config.yml中设置属性permalink属性用于设置文章在静态文件生成后的路径

permalink: :year/:month/:day/:title/
permalink_defaults:

2.比如文章hello-world.md的源路径为

/source/_posts/hello-world.md

3.生成静态文件后的路径为

/path/to/public/2021/03/10/hello-world/index.html

二、变量

1.Hexo提供了以下变量来生成永久链接

变量描述
:year发表年份(4位数字)
:month发表月份(2位数字)
:i_month发表月份(没有前置0)
:day发表日(2位数字)
:i_day发表日(没有前置0)
:title文件名
:post_title文章标题
:post_title文章ID
:category类别。如果没有分类,那么使用属性default_category的值

2.比如文章配置块内容如下:

title: Hello World
date: 2013-07-14 17:01:34
categories:
    - foo
    - bar

3.那么可以定义如下的永久链接

:year/:month/:day/:title/ 
:year-:month-:day-:title.html
:category/:title

4.生成的静态文件如下

2013/07/14/hello-world/index.html
2013-07-14-hello-world.html
foo/bar/hello-world

三、语言设置

permalink_defaults:
  lang: en

插件rozbo/hexo-abbrlink支持生成更加常见的永久链接,其实现方式

对标题+时间进行md5然后再转base64,保存在front-matter中。

1.安装

npm install hexo-abbrlink --save

2.修改_config.yml

permalink: posts/:abbrlink.html

3.可以修改生成的算法和表示方式

算法:crc16(默认)或crc32
表示:dec(默认,十进制)或hex(十六进制)

4.配置方式

# abbrlink config
abbrlink:
  alg: crc32  #support crc16(default) and crc32
  rep: hex    #support dec(default) and hex

5.编译后会在源文件的配置块中插入

abbrlink: xxxxx

0

评论区