一、官网插件

所有插件,均可在Hexo官网插件中找到

目前本站已安装插件:

生成永久链接(hexo-abbrlink)
Makedown渲染器(hexo-renderer-markdown-it-plus)
搜索功能(hexo-generator-search)
字数统计(hexo-wordcount)


二、生成永久链接(hexo-abbrlink)

hexo-abbrlink插件通过算法,可以优化博客路径,默认路径https://blog.crygcat.top/2023/03/01/【Hexo】Hexo常用插件推荐,还会带上标题,这款插件可以将路径优化为https://blog.crygcat.top/posts/c0ee085a等等,支持16进制。

1. 安装插件

1
npm install hexo-abbrlink --save

2. 配置插件

_config.yml文件末尾,添加如下配置项(记得把原来的permalink:注释或者删除):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#设置永久链接
permalink: posts/:abbrlink.html # 此处可以自己设置,也可以直接使用 :/abbrlink
abbrlink:
alg: crc16 #算法: crc16(default) and crc32
rep: dec #进制: dec(default) and hex
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. This only updates abbrlink rather than other front variables.

Abbrlink插件拥有两项设置选项:
alg: 算法(目前支持crc16crc32算法,默认值是crc16)
rep: 形式(生成的链接可以是十六进制格式也可以是十进制格式,默认值是十进制格式)

示例:

crc16 & hex
https://test.com/posts/55c6.html
crc16 & dec
https://test.com/posts/43212.html

crc32 & hex
https://test.com/posts/6ec16a2c.html
crc32 & dec
https://test.com/posts/1521457752.html

3. 常见问题

  1. 刚使用这个插件后,阅读人数和评论都会变为0,介意慎用!

三、更换Makedown渲染器

由于 Hexo 默认的 Markdown 渲染器(hexo-renderer-marked)不支持复杂公式,涉及到一些数学公式时,就无法显示和使用,这时候就需要更换 Markdown 渲染器。
本站使用的渲染器为hexo-renderer-markdown-it-plus

1. 卸载旧渲染器

1
npm uninstall hexo-renderer-marked --save

2. 安装新渲染器

以下列出几种常用的Makedown渲染器

hexo-renderer-marked

Hexo 默认的 Markdown 的渲染器,不支持 Mathjax,不支持插件扩展,不支持 emoji 表情
项目地址: https://github.com/hexojs/hexo-renderer-marked
安装命令:

1
npm install hexo-renderer-marked --save

hexo-renderer-kramed

基于hexo-renderer-marked,支持 Mathjax,不支持插件的扩展,不支持 emoji 表情
项目地址: https://github.com/sun11/hexo-renderer-kramed
安装命令:

1
npm install hexo-renderer-kramed --save

hexo-renderer-markdown-it

渲染速度比hexo-renderer-marked快,支持脚注(上标,下标,下划线),支持 emoji 表情,支持 LaTeX,扩展需要另外通过 npm 安装,你可以在 这里 找到更多拓展。
项目地址: https://github.com/hexojs/hexo-renderer-markdown-it
安装命令:

1
npm install hexo-renderer-markdown-it --save

hexo-renderer-markdown-it-plus

hexo-renderer-markdown-it的基础上默认自带许多插件,可以直接使用
项目地址: https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus
安装命令:

1
npm install hexo-renderer-markdown-it-plus --save

四、搜索功能(hexo-generator-search)

1. 安装插件

1
npm install hexo-generator-search --save

2. 配置插件

_config.yml文件末尾,添加如下配置项:

1
2
3
4
5
search:
path: search.xml
field: all # post:文章范围、page:页面范围、all:覆盖所有
content: true # 内容是否包含每一篇文章的全部内容
template: # ./search.xml 指定定制的XML模板

打开主题配置文件,配置搜索功能:

1
2
3
4
5
6
#开启本地搜索,即可我们正常的使用
# Local search
local_search:
enable: true
preload: false
CDN:

本站使用的是butterfly,不同主题可能配置方式不同,请根据自己的主题,更改相应操作


五、字数统计(hexo-wordcount)

1. 安装插件

1
npm install hexo-wordcount --save

2. 配置插件

打开主题配置文件,配置字数统计功能:

1
2
3
4
5
6
7
# wordcount (字數統計)
# see https://butterfly.js.org/posts/ceeb73f/#字數統計
wordcount:
enable: true
post_wordcount: true
min2read: true
total_wordcount: true

本站使用的是butterfly,不同主题可能配置方式不同,请根据自己的主题,更改相应操作


六、添加 RSS 订阅(hexo-generator-feed)

RSS 的全称是 Really Simple Syndication(简易信息聚合),它是一种消息来源的格式规范,网站可以按照这种格式规范提供文章的标题、摘要、全文等信息给订阅用户,用户可以通过订阅不同网站 RSS 链接的方式将不同的信息源进行聚合,在一个工具里阅读这些内容。当网站内容更新时,可以通过订阅 RSS 源在 RSS 阅读器上获取更新的信息

1. 安装插件

1
npm install hexo-generator-feed --save

2. 配置插件

_config.yml文件末尾,添加如下配置项:

1
2
3
4
5
6
7
8
9
10
feed:
enable: true
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: " "
order_by: -date

更多配置信息,可以在这里查看hexo-generator-feed

配置完成之后,重新部署,在你的网站域名后添加/atom.xml即可查看。

1
https://blog.crygcat.top/atom.xml

七、添加看板娘

在你的 Hexo 里放上一只二次元看板娘
项目地址: hexo-helper-live2d
演示: https://l2dwidget.js.org/dev.html
Hexo插件-看板娘

1. 安装插件

Git Bash中安装模块:

1
npm install --save hexo-helper-live2d

或者

1
yarn add hexo-helper-live2d

2. 配置插件

_config.yml文件末尾,添加如下配置项:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
live2d:
enable: true
scriptFrom: local
pluginRootPath: live2dw/
pluginJsPath: lib/
pluginModelPath: assets/
tagMode: false
debug: false
model:
use: live2d-widget-model-wanko ## 更换为你的模型
display:
position: right
width: 150
height: 300
mobile:
show: true
react:
opacity: 0.7

现有所有模型:https://github.com/xiazeyu/live2d-widget-models
安装后的模型,可以在packages/中看到
安装语句:

1
npm install 模型的包名

完成后,将包名输入位于_config.ymlmodel.use中。

1
2
model:
use: 安装的模型的包名