织梦导航外部链接新窗口打开加上nofollow属性
发布时间:2022-09-02 10:34:36 所属栏目:教程 来源:互联网
导读:SEO优化中,对织梦主导航的设计非常讲究,主导航链接是栏目链接,一般直接跳转;如果主导航链接是外部链接,不可直接跳出,会增加网站的跳出率。此类链接应设置在新窗口打开target=_blank,并且用nofollow不让蜘蛛抓取该链接。下面是修改方法。 打开/include
SEO优化中,对织梦主导航的设计非常讲究,主导航链接是栏目链接,一般直接跳转;如果主导航链接是外部链接,不可直接跳出,会增加网站的跳出率。此类链接应设置在新窗口打开target="_blank",并且用nofollow不让蜘蛛抓取该链接。下面是修改方法。 打开/include/taglib/channel.lib.php,找到 01 if($needRel) 02 03 { 04 05 $row['sonids'] = GetSonIds($row['id'], 0, false); 06 07 if($row['sonids']=='') $row['rel'] = ''; 08 09 else $row['rel'] = "id']}'"; 10 11 }下面增加 $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); 下面增加 01 $linkOkstr = str_replace("~target~",$row['target'],$linkOkstr); 02 03 $linkOkstr = str_replace("~nofollow~",$row['nofollow'],$linkOkstr); 04 05 在导航标签里面增加新标签[field:target/]、[field:nofollow/]即可,这两个标签根据实际情况使用。 06 07 {dede:channel type='self' currentstyle=" 08 09 <li class='thisclass'><a href='~typelink~' ~target~ ~nofollow~>~typename~</a></li>"} 10 11 <li><a href='[field:typeurl/]' [field:target/] [field:nofollow/]>[field:typename/]</a></li> 12 13 {/dede:channel} (编辑:鞍山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |