从SEO角度出发,我们应该禁止搜索引擎对网站分页的抓取

  • A+
所属分类:WordPress教程

我们采用wordpress进行网站建设的时候,在评论的分页的时候,其实是存在重复内容的,因为评论分页的内容正文都一样,并且 keywords 和 description 也相同,这样对搜索引擎来说,是不友好的,存在恶意重复内容,会被降权之说,那么,我们应该禁止搜索引擎对网站分页的抓取!

方法就是,在主题文件的header.php头部文件里,加个判定,然后用

  1. <meta name="robots" content="noindex, nofollow" />

来进行禁止抓取!下面直接给完整代码吧:

  1. <?php if( is_single() || is_page() ) {
  2.     if( function_exists('get_query_var') ) {
  3.         $cpage = intval(get_query_var('cpage'));
  4.         $commentPage = intval(get_query_var('comment-page'));
  5.     }
  6.     if( !emptyempty($cpage) || !emptyempty($commentPage) ) {
  7.         echo '<meta name="robots" content="noindex, nofollow" />';
  8.         echo "\n";
  9.     }
  10. }
  11. ?>

在原有的 meta 标签下加入以上代码即可!OK。。。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: