Hexo Abbrlink短链接入教程

技术教程
提示

本文由人工智能辅助创作,已经过人工审核,确保内容准确性和实用性。请在使用前自行验证相关内容。

Hexo Abbrlink短链接入教程

Hexo Abbrlink 是一个 Hexo 插件,用于生成短链接。它可以帮助你将长链接转换为更简短的形式,便于分享和管理。

在你的 Hexo 项目目录中,运行以下命令安装 Hexo Abbrlink 插件:

1
npm install hexo-abbrlink --save

在你的 Hexo 项目根目录下的 _config.yml 文件中添加以下配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# hexo-abbrlink
abbrlink:
alg: crc32 #支持crc16和crc32算法(默认crc16)
rep: hex #支持dec和hex值(默认dec)
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.

在你的 Hexo 文章中,你可以使用以下语法来指定生成短链接:

1
abbrlink: your_custom_abbrlink

如果你没有指定 abbrlink,插件会自动生成一个短链接。

生成短链接

在你完成文章编写后,运行以下命令生成短链接:

1
hexo cl && hexo g

查看短链接

生成短链接后,你可以在 Hexo 生成的静态文件中查看短链接。通常,短链接会被存储在 db.json 文件中,你可以在 Hexo 的 public 目录下找到它。

注意事项

  • 确保在使用 Hexo Abbrlink 之前,已经安装了 Hexo 和相关依赖。
  • 如果你在使用过程中遇到问题,可以查看 Hexo Abbrlink 的 GitHub 仓库
  • 请确保在使用短链接时,链接的目标页面是有效的。
  • 如果你需要更改短链接的生成规则,可以在 _config.yml 文件中进行相应的配置。

参考资料

提示

本文由人工智能辅助创作,已经过人工审核,确保内容准确性和实用性。请在使用前自行验证相关内容。

本文作者:墨尘

本文链接: https://blog.sord.top/posts/bd39895e.html

文章默认使用 CC BY-NC-SA 4.0 协议进行许可,使用时请注意遵守协议。

评论