hexo-filter-nofollow 是一个自动为 Hexo 博客中的外链添加 rel="external nofollow noreferrer"
的插件。git
<!-- more -->github
GitHub | English Version正则表达式
插件目前由我和 curbeng 维护,已成为 Hexo 官方插件。npm
hexo-filter-nofollow 会为你的博客中的外链自动添加 rel="external nofollow noreferrer"
属性,从而 改善你的网站的安全性和 SEO。安全
$ npm i hexo-filter-nofollow --save
若是你使用 yarn 做为你的 Hexo 的包管理器,你也能够使用下述命令:bash
$ yarn add hexo-filter-nofollow
nofollow: enable: true field: site exclude: - 'exclude1.com' - 'exclude2.com'
true
field - 插件的处理范围,默认值为 site
,可选 post
或 site
hexo
post
- 仅处理文章内容site
- 处理全站全部页面exclude - 域名白名单,不一样的子域名视为不一样的域名(如 www
)post
exclude1.com
不包括 www.exclude1.com
或 en.exclude1.com
hexo-autonofollow 是由 liuzc 在 2016 年开发的为 Hexo 全部页面中的外链添加 rel="external nofollow"
属性的插件。hexo-filter-nofollow 相比 hexo-autonofollow 有如下区别:性能
enable
配置 默认值为 true
,默认启用插件field
配置,支持设置插件处理范围若是你以前已经安装了 hexo-autonofollow,能够直接卸载 hexo-autonofollow 并安装 hexo-filter-nofollow。hexo-filter-nofollow 的配置和 hexo-autonofollow 的配置彻底兼容。网站
虽然 hexo-autonofollow 三年没有更新了,可是除了 cheerio 版本过旧、存在安全漏洞之外,其实并不影响使用。NodeJS 上没有高性能的 DOM 解析库;cheerio 已是最快的了,可是用来遍历 Hexo 生成的全部页面时耗费的时间仍然堪忧。Hexo 已经提出了 使用 Native API 代替 cheerio 的提案,hexo-filter-nofollow 正是 使用正则表达式代替 DOM 解析库 的一次实验和尝试。