我的知识记录

pbootcms百度编辑器UEDITOR给超链接默认添加rel="nofollow"标签

image

1. 修改 link.html 文件

  • 找到文件路径:\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
修改为

在上述代码中新增一行 'rel': 'nofollow',,修改后如下:

 
'href' : href, 'target' : $G("target").checked ? "_blank" : '_self', 'title' : $G("title").value.replace(/^\s+|\s+$/g, ''), 'rel': 'nofollow', '_href':href

2. 修改 ueditor.config.js 文件

  • 找到文件路径:\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 标签属性列表中新增 'rel' 属性,修改后如下:

 
a: ['target', 'href', 'title', 'class', 'style','name','rel','id'], abbr: ['title', 'class', 'style'], abbr: ['title', 'class', 'style'], area: ['shape', 'coords', 'href', 'alt'],

测试与验证

  1. 后台测试

    • 登录 PbootCMS 后台。
    • 使用 UEditor 编辑器插入一个超链接。
    • 检查生成的 HTML 代码,确认是否自动添加了 rel="nofollow" 属性。
  2. 示例效果

    <a href="https://example.com" target="_blank" rel="nofollow">示例链接</a>

注意事项

  1. 备份原始文件

    • 在修改前,建议备份 link.html 和 ueditor.config.js 文件,以便在出现问题时快速恢复。
  2. 缓存清理

    • 如果修改后未生效,可能是浏览器缓存导致。建议清除浏览器缓存或强制刷新页面(Ctrl + F5)。
  3. SEO 最佳实践

    • rel="nofollow" 的作用是告诉搜索引擎不要跟踪该链接,从而避免权重流失。
    • 对于外部链接(如广告、友情链接等),建议使用 rel="nofollow";而对于内部链接或重要内容链接,则无需添加。

pbootcms百度编辑器UEDITOR给超链接默认添加rel="nofollow"标签

标签:

更新时间:2025-12-06 17:39:41

上一篇:PbootCMS缩略图上传图片变模糊为什么?(PbootCMS后台缩略图上传模糊问题的解决方案)

下一篇:PbootCMS在阿里云主机上邮件发送失败:服务器已经禁用stream_socket_client和fsockopen