codemonauts / craft-redactor-nofollow
Craft CMS 插件,用于扩展 Redactor 的链接模块,增加 nofollow 关系属性。
2.1.0
2022-12-14 15:42 UTC
Requires
- craftcms/cms: ^4.0.0
- craftcms/redactor: ^3.0.0
README
插件,用于在 Redactor 的链接模块中添加复选框,以便为链接添加 rel="nofollow"
属性。
背景
对于许多网站来说,设置链接为 rel="nofollow"
非常重要。Redactor 提供了一个选项来设置所有链接为 nofollow。然而,这通常不是必需的,也不是 SEO 中的常规做法。通过这个插件,可以在链接编辑模态中为每个链接单独启用此属性。
要求
- Craft CMS >= 4.0.0
- Craft Redactor 插件 >= 3.0.0
安装
打开终端并进入您的 Craft 项目目录
cd /path/to/project
composer require codemonauts/craft-redactor-nofollow
./craft plugin/install nofollow
您也可以通过 Craft 控制面板中的插件商店安装插件。
配置
将新插件添加到 Redactor 配置文件中
{ "plugins": [ "nofollow" ] }
您可以配置在添加新链接时,链接对话框中的复选框是否默认勾选。只需将以下配置添加到您的 Redactor 配置文件中
{ "linkDefaultNoFollow": true }
HTMLPurifier 会默认移除所有 Redactor 字段中的 nofollow
,因此您不需要为单个字段禁用整个 HTMLPurifier。相反,您应该在 config/htmlpurifier/Default.json
中添加以下行
{ "Attr.AllowedRel": [ "nofollow" ] }
由 codemonauts 献爱❤