Hexo站点建设之——文章链接Permalinks

一 几种常见的Permalinks

  • 默认链接样式
  • 中文转拼音hexo-permalink-pinyin
  • 插件:hexo-abbrlink
  • 插件:exo-abbrlink2
  • 自定义pid/urlname方式

二 默认链接样式

2.1 变量

变量描述
:year文章的发表年份(4 位数)
:month文章的发表月份(2 位数)
:i_month文章的发表月份(去掉开头的零)
:day文章的发表日期 (2 位数)
:i_day文章的发表日期(去掉开头的零)
:hour文章发表时的小时 (2 位数)
:minute文章发表时的分钟 (2 位数)
:second文章发表时的秒钟 (2 位数)
:title文件名称 (relative to “source/_posts/“ folder)
:name文件名称
:post_title文章标题
:id文章 ID (not persistent across cache reset)
:category分类。如果文章没有分类,则是 default_category 配置信息。
:hashSHA1 hash of filename (same as :title) and date (12-hexadecimal)

2.2 样式

参数结果
:year/:month/:day/:title/2013/07/14/hello-world/
:year-:month-:day-:title.html2013-07-14-hello-world.html
:category/:title/foo/bar/hello-world/
:title-:hash/hello-world-a2c8ac003b43/

2.3 如何使用

source/_posts/lorem/hello-world.md
title: Hello World
date: 2013-07-14 17:01:34
categories:
- foo
- bar

三 中文转拼音hexo-permalink-pinyin

3.1 样式

标题:我的个人博客
转换后:https://[你的网站域名]/posts/wo-de-ge-ren-bo-ke.html

3.2 如何使用

插件地址:hexo-permalink-pinyin
插件安装
npm i hexo-permalink-pinyin --save
插件配置(config.yml )
# https://github.com/viko16/hexo-permalink-pinyin
permalink_pinyin:
  enable: true
  separator: '-' # default: '-'

3.3 可能存在的问题

可能会出现分类存在大写字母,那么在URL访问的时候不能访问到该分类的详情页

四 hexo-abbrlink(推荐)

4.1 样式

标题:我的个人博客
转换后:
crc16 & hex
https://[你的网站域名]/posts/66c8.html

crc16 & dec
https://[你的网站域名]/posts/65535.html

crc32 & hex
https://[你的网站域名]/posts/8ddf18fb.html

crc32 & dec
https://[你的网站域名]/posts/1690090958.html

4.2 如何使用

插件地址:hexo-abbrlink
插件安装
npm install hexo-abbrlink --save
插件配置(config.yml )
permalink: posts/:abbrlink.html
abbrlink:
  alg: crc32  # 算法:crc16(default) and crc32
  rep: hex    # 进制:dec(default) and hex
#add v7.8.0
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

五 插件:hexo-abbrlink2(不推荐)

5.1 样式

标题:我的个人博客
转换后:https://[你的网站域名]/posts/1.html

5.2 如何使用

插件地址:hexo-abbrlink2

插件安装

npm install hexo-abbrlink2 --save

插件配置(config.yml )

permalink: posts/:abbrlink/
abbrlink:
  start: 1000 # the first id, default 0

5.3 存在的问题

  • 文章页面没有:abbrlink参数说明文章id
  • 使用过hexo-abbrlink后,文章链接对此无效

六 自定义pid/urlname方式

6.1 样式

标题:我的个人博客
转换后:https://[你的网站域名]/posts/1.html

6.2 如何使用

_config.yml
permalink: /posts/:pid/
文章配置pid参数
---
title: 第一篇博客
categories: 
tags: 
pid: 1
date: 2020-12-10 11:20:53
---
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值