Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

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

dedecms教程:织梦教程导航外部链接新窗口打开加上nofollow属性!SEO优化中,对织梦主导航的设计非常讲究,主导航链接是栏目链接,一般直接跳转。

dedecms教程:织梦教程导航外部链接新窗口打开加上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="
<li class='thisclass'><a href='~typelink~' ~target~ ~nofollow~>~typename~</a></li>"}
<li><a href='[field:typeurl/]' [field:target/] [field:nofollow/]>[field:typename/]</a></li>
{/dede:channel}
温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
编程技巧

Discuz密码错误次数过多,请15分钟后重新登录的修改方法

2020-10-17 0:00:00

编程技巧

织梦提交留言后刷新重复提交的解决教程

2020-10-24 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索