栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > dedecms

织梦导航外部链接新窗口打开加上nofollow属性

dedecms 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

织梦导航外部链接新窗口打开加上nofollow属性

 SEO优化中,对织梦主导航的设计非常讲究,主导航链接是栏目链接,一般直接跳转;如果主导航链接是外部链接,不可直接跳出,会增加网站的跳出率。此类链接应设置在新窗口打开target="_blank",并且用nofollow不让蜘蛛抓取该链接。下面是修改方法。

  打开/include/taglib/channel.lib.php,找到

 

 if($needRel)

  {

  $row['sonids'] = GetSonIds($row['id'], 0, false);

  if($row['sonids']=='') $row['rel'] = '';

  else $row['rel'] = "id']}'";

  }

  

下面增加

  $row['target'] = ($row['ispart']==2) ? "target = '_blank'" : "target = '_self'"; //新窗口打开

  $row['nofollow'] = ($row['ispart']==2) ? "rel = 'nofollow'" : "rel = 'follow'"; //nofollow属性

  需要currentstyle支持这两个属性,继续往下找到

  $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);

  

下面增加

  $linkOkstr = str_replace("~target~",$row['target'],$linkOkstr);

  $linkOkstr = str_replace("~nofollow~",$row['nofollow'],$linkOkstr);

  在导航标签里面增加新标签[field:target/]、[field:nofollow/]即可,这两个标签根据实际情况使用。

  {dede:channel type='self' currentstyle="

  
  • ~typename~
  • "}   
  • [field:typename/]
  •   {/dede:channel}

    转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/7830.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号