在网站的SEO优化过程中,rel=”nofollow”属性的使用变得越来越普遍。然而,百度编辑器UEDITOR并未默认添加这个标签,这会使得在引入其他站点URL链接时,流失蜘蛛并导致网站权重下降。因此,在本篇文章中,我们将教您如何将ueditor的link自动添加rel=”nofollow”属性。
首先,您需要找到/core/extend/ueditor/dialogs/link/link.html文件,并修改第81行的代码。原始代码如下:
'href': href,
'target': $G("target").checked ? "_blank" : '_self',
'title': $G("title").value.replace(/^\s+|\s+$/g, ''),
'_href': href
您需要将其修改为以下代码:
'href': href,
'target': $G("target").checked ? "_blank" : '_self',
'title': $G("title").value.replace(/^\s+|\s+$/g, ''),
'rel': 'nofollow',
'_href': href
这里我们添加了’rel’: ‘nofollow’,这样就可以自动添加rel=”nofollow”属性了。
接下来,您需要找到/core/extend/ueditor/ueditor.config.js文件,并修改第370行的代码。原始代码如下:
a: ['target', 'href', 'title', 'class', 'style','name','id'],
abbr: ['title', 'class', 'style'],
abbr: ['title', 'class', 'style'],
area: ['shape', 'coords', 'href', 'alt'],
您需要将其修改为以下代码:
a: ['target', 'href', 'title', 'class', 'style','name','rel','id'],
abbr: ['title', 'class', 'style'],
abbr: ['title', 'class', 'style'],
area: ['shape', 'coords', 'href', 'alt'],
这里我们添加了’rel’属性,这样就可以自动添加rel=”nofollow”属性了。
完成以上两个步骤后,您就可以实现ueditor的link自动添加rel=”nofollow”属性了。在网站后台测试添加链接时,您也可以确认是否已成功添加。