0%

文章使用短网址的记录

2020年11月14日,舍无由发现以往所发博文的网址都很长,不方便分享、被检索到。
所以考虑使用短网址,参考了大佬的文章SEO优化:Hexo-abbrlink插件生成永久固定链接

我的更改过程,简单记录如下,如需详细过程,可参见上面大佬文章。

第1步:打开博客根目录_config.yml文件

修改博客根目录的_config.yml文件,原来的代码段如下:

1
2
3
4
5
6
7
8
9
# URL
## If your site is put in a subdirectory, set url as 'http://example.com/child' and root as '/child/'
url: https://QinXiuFuHui.github.io
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

第2步:更改代码

舍无由将上面这段代码更改为如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#设置永久链接,20201114日舍无由新增五行,包含该行注释(该段注释算作一行),并把原来的permalink: :year/:month/:day/:title/注释掉,操作过程依据https://www.heson10.com/next/posts/31426.html
permalink: posts/:abbrlink.html # 此处可以自己设置,也可以直接使用 :/abbrlink
abbrlink:
alg: crc16 #算法: crc16(default) and crc32
rep: dec #进制: dec(default) and hex

# URL
## If your site is put in a subdirectory, set url as 'http://example.com/child' and root as '/child/'
url: https://QinXiuFuHui.github.io
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

保存_config.yml文件。

第3步:发布

然后在博客根目录下,右键单击启动Git Bash Here,使用一键三连的命令hexo clean && hexo g -d
将本地数据部署到远端服务器。

第4步:检验效果

执行完后,打开自己网站,发现以前的博文长网址已经变为了短网址。
但是之前分享给他人的长网址已经失效了。