菜单
菜单
文章目录
  1. hexo-deployer-git
  2. hexo-abbrlink
  3. hexo-addlink (x)
  4. hexo-autonofollow
  5. hexo-external-link (x)
  6. hexo-generator-feed
  7. hexo-generator-sitemap
  8. hexo-git-backup
  9. hexo-neat
  10. hexo-helper-live2d
  11. hexo-image-cloudflare
  12. hexo-search
  13. hexo-wordcount
  14. 结束语

本站所用插件汇总

在此将本站所用插件进行一个汇总,并记录插件功能及其配置方法。

插件安装更新采用 Yarn 包管理器管理。

在此记录以便不时之需!!!

2020-11-04 新增插件 hexo-image-cloudflare,让图片缓存到 Cloudfare 上。

hexo-deployer-git

必装插件,用于将hexo生成的静态文件提交到Github仓库。

安装:

yarn add hexo-deployer-git

用法:

修改根目录config.yml文件中的

deploy:
- type: git
repo:
github: git@github.com:Senorui/senorui.github.io.git
branch: master

此插件可以固定文章链接,使文章URL唯一化,有利于SEO。

插件地址: https://github.com/rozbo/hexo-abbrlink

安装:

yarn add hexo-abbrlink

使用:

修改根目录config.yml文件中的永久链接为

permalink: posts/:abbrlink/
abbrlink:
alg: crc16 # 算法:crc16(default) and crc32
rep: hex # 进制:dec(default) and hex
&
permalink: posts/:abbrlink.html
abbrlink:
alg: crc16 # 算法:crc16(default) and crc32
rep: hex # 进制:dec(default) and hex

alg – Algorithm,rep – Represent参数如下:

crc16 & hex
https://post.zz173.com/posts/66c8.html

crc16 & dec
https://post.zz173.com/posts/65535.html
crc32 & hex
https://post.zz173.com/posts/8ddf18fb.html

crc32 & dec
https://post.zz173.com/posts/1690090958.html

本插件可以在文章尾部添加当前文章链接,注明版权,有利于SEO。

插件地址: https://github.com/acwong00/hexo-addlink

安装:

yarn add hexo-addlink

使用:

根目录config.yml文件中添加

# 版权信息
addlink:
before_text: __本文作者__: <a href="作者地址(一般为本站地址)" target="_blank">Senorui</a><br/>__本文地址__:
after_text: <br/>__版权声明__: 本博客所有文章除特别声明外,均为原创且采用 <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" rel="external nofollow noopener noreferrer">知识共享署名4.0</a> 国际许可协议进行许可<br>

此插件不适配 Hexo 5.0,作者和声明标题样式会缺失;不排除是我主题不适配!!

hexo-autonofollow

为所有外部链接添加rel =“ external nofollow”,并添加target =“ _ blank”使其在新窗口或新标签中打开外部链接,有利于SEO。

地址: https://github.com/liuzc/hexo-autonofollow

安装:

yarn add hexo-autonofollow

使用:

根目录config.yml文件中添加

# 外链添加nofollow标签
nofollow:
enable: true
exclude:
- senorui.top #本站域名

跳转外链相关插件。自动为所有html文件中外链的a标签生成对应的属性。 比如设置 target='_blank', rel='external nofollow noopener noreferrer' 告诉搜索引擎这是外部链接,不要将该链接计入权重。 同时自动生成外链跳转页面,默认在根目录下go.html;

插件地址: https://github.com/hvnobug/hexo-external-link

安装:

yarn add hexo-external-link

使用:

在根目录config.yml文件中添加

# 外链跳转
hexo_external_link:
enable: true
enable_base64_encode: false
url_param_name: 'url'
html_file_name: 'go.html'
target_blank: true
link_rel: 'external nofollow noopener noreferrer'
domain: '' # 如果开启了防盗链,填写你的域名
safety_chain: true

参数

变量 默认 说明
enable false 是否开启本插件
enable_base64_encode false 是否对跳转url使用base64编码
url_param_name u url参数名,在跳转到外链传递给html_file_name的参数名
html_file_name go.html 跳转到外链的页面文件路径
target_blank true 是否为外链的a标签添加target='_blank'
link_rel external nofollow noopener noreferrer 设置外链的a标签的rel属性
domain window.location.host 或者为空 如果开启了防盗链,除了 localhost 和 domain 之外调用会跳到主页,同时也是判断链接是否为外链的依据
safety_chain true go.html 为了防止外链盗用 对域名进行的判断

hexo-generator-feed

为hexo博客添加RSS订阅功能

插件地址: https://github.com/hexojs/hexo-generator-feed

安装:

yarn add hexo-generator-feed

使用:

在根目录config.yml文件中添加

feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '
order_by: -date
icon: icon.png
autodiscovery: true
template:

集成RSS订阅功能的主题,直接安装此插件,在主题配置文件中修改RSS链接为 /atom.xml 即可,无需在根目录下配置。

hexo-generator-sitemap

为hexo博客添加站点地图文件sitemap

插件地址: https://github.com/hexojs/hexo-generator-sitemap

安装:

yarn add hexo-generator-sitemap

使用:

在根目录config.yml文件中添加

sitemap:
path: sitemap.xml
template: ./sitemap_template.xml
rel: false
tags: true
categories: true

若要排除文章或者页面,只需添加sitemap: false到文章或者页面的 front matter 处即可。

另有 hexo-generator-baidusitemap 插件,其生成百度特殊站点地图文件 baidusitemap.xml

hexo-git-backup

博客源码一键备份到Gihub仓库等源码托管平台的插件。

插件地址: https://github.com/coneycode/hexo-git-backup

安装:

yarn add hexo-git-backup

若Hexo版本低于3.0,则安装

yarn add hexo-git-backup@0.0.91

使用:

在根目录config.yml文件中添加

# Backup 源码备份
backup:
type: git
theme: fexo #主题名
message: 新文章发表 #备份说明
repository:
github: git@github.com:Senorui/Blog.git,Blog

执行命令即可一键发布文章并备份源码

hexo clean && hexo g && hexo d && hexo b

hexo-neat

压缩和删除html或其他脚本中的空格和无用的换行符,注释等,以减少网页文件的响应速度,实现网络的快速响应。

插件地址: https://github.com/rozbo/hexo-neat

安装:

yarn add hexo-neat

用法:

在根目录config.yml文件中添加

# hexo-neat
neat_enable: true
# 压缩 html
neat_html:
enable: true
exclude:
# 压缩 css
neat_css:
enable: true
exclude:
- '**/*.min.css'
- '**/*.css.map'
# 压缩 js
neat_js:
enable: true
mangle: true
output:
compress:
exclude:
- '**/*.min.js'

根据自己的来合理调整压缩和不需要压缩的文件。

hexo-helper-live2d

向你的Hexo里放上一只萌萌哒二次元看板娘!

插件地址: https://github.com/EYHN/hexo-helper-live2d

安装依赖:

yarn add hexo-helper-live2d

安装模型:

模型仓库地址: https://github.com/xiazeyu/live2d-widget-models

yarn add {packagename}
# e.g
yarn add live2d-widget-model-koharu

在根目录config.yml文件中添加

# 看板娘
live2d:
enable: true #是否开启看板娘
scriptFrom: local
pluginRootPath: live2dw/
pluginJsPath: lib/
pluginModelPath: assets/
tagMode: false
debug: false
model:
use: live2d-widget-model-koharu #换成自己安装的模型
display:
position: left #显示在左or右
width: 158
height: 233
mobile:
show: false # 是否在移动设备上显示
scale: 0.4 # 移动设备上的缩放
react:
opacityDefault: 0.7
opacityOnHover: 0.4

hexo-image-cloudflare

一个能够使用 Cloudflare来缓存博客图像的hexo插件,其由 【images.weserv.nl】 驱动。

插件地址: https://github.com/njzjz/hexo-image-cloudflare

安装:

yarn add hexo-image-cloudflare

可缓存外链图片和本地图片,只需在博客根目录配置好博客域名。

为博客添加站内搜索功能,此插件为本主题 Fexo作者写的,优先适配本主题。

插件地址: https://github.com/forsigner/hexo-search

安装:

yarn add hexo-search

在根目录config.yml文件中添加

search:
path: search.json
source: all # other values: posts, pages
trim_html: false

其他主题推荐另一个大众化一点的: https://github.com/wzpan/hexo-generator-search

hexo-wordcount

可以为文章添加字数统计和阅读时长统计,以及站点总字数统计。

插件地址: https://github.com/willin/hexo-wordcount

安装:

yarn add hexo-wordcount

使用:

Swig
Post Count:

<span class="post-count">{{ wordcount(post.content) }}</span>

Post Minutes to Read:

<span class="post-count">{{ min2read(post.content) }}</span>

Total Count:

<span class="post-count">{{ totalcount(site) }}</span>

Ejs
Post Count:

<span class="post-count"><%= wordcount(post.content) %></span>

Post Minutes to Read:

<span class="post-count"><%= min2read(post.content) %></span>

Total Count:

<span class="post-count"><%= totalcount(site) %></span>

Jade
Post Count:

span.post-count= wordcount(post.content)

Post Minutes to Read:

span.post-count= min2read(post.content)

Total Count:

span.post-count= totalcount(site)

本站主题适配为在article.ejs中的

<%- partial('component/category') %>

之后插入

<span class="post-count">
<span>
<i class="fa fa-file-word"></i>
&nbsp字数 <%= wordcount(post.content) %>
</span>

<span class="post-count">
<span>
<i class="fa fa-clock"></i>
&nbsp耗时 <%= min2read(post.content) %> 分</span>
</span>

效果如下:

wordcount

结束语

除了Hexo自带的插件之外,自己安装的插件中,有4个与SEO相关;其余1个美化类插件,4个工具型插件。

以上为本站所需插件!!!

本文作者: Senorui

本文链接: https://senorui.top/posts/e682.html

版权声明: 本站所有文章除特别声明外,均采用【CC BY-NC-ND 4.0】国际许可协议,若转载请注明出处!

支持一下
知识无价,欢迎打赏🍖
  • 微信扫一扫
  • 支付宝扫一扫