简述

问题描述

前情提示

系统:

一说

  • 同步更新最新版、完整版请移步PUSDN Powered By PUSDN - 平行宇宙软件开发者网www.pusdn.com ,转载请标明出处!

  • 部分截图、链接等因过期、更换域名、MD语法等可能不显示,可联系反馈(备注好博文地址),谢谢❤

  • 带有#号、删除线、不操作、不执行字样的为提示或者备份bash,实际不执行

为什么配置这个呢,主要是想生成永久唯一链接,方便分享、保存、也方便SEO优化。因为默认生成链接是如下格式

在这里插入图片描述

默认规则:permalink: :year/:month/:day/:title/如果有中文,那么链接中也会有中文,非常不利于理解。

这里用到的是hexo-abbrlink:https://github.com/Rozbo/hexo-abbrlink

  1. 安装

进入站点目录:cd /home/myblog

npm install hexo-abbrlink --save

  1. 配置站点文件

原配置如下:

1
2
3
4
5
6
7
8
9
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
permalink: :year/:month/:day/:title/
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

修改为:

1
2
3
4
5
6
7
8
9
10
11
12
13
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
# permalink: :year/:month/:day/:title/
permalink: blog/:abbrlink/ # 此处可以自己设置,也可以直接使用 :/abbrlink
abbrlink:
alg: crc32 #算法: crc16(default) and crc32
rep: hex #进制: dec(default) and hex
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
  1. 进行hexo三连。

清理:hexo clean

重新生成:hexo g

启动:hexo s

以上均是在站点根目录执行:/home/myblog

查看效果图如下:

在这里插入图片描述