开发者

Hiding part of a webpage from search engines? [closed]

Close开发者_运维百科d. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about programming within the scope defined in the help center.

Closed 9 years ago.

Improve this question

I'd like to make part of a webpage ignored by search engines. Is this possible? I want search engines to notice only the title and content, not comments, menus, and etc.

Example

<p>content 1</p>
<p class='crawlers-cannot-see-this'>content 2</p>


Use dynamic content through Javascript or simply use an iframe.

There is nothing that will otherwise tell a spider not to index a block of code or content.

For a server side distinction use $_SERVER['HTTP_USER_AGENT'] but like I've stated it's not necessarily the most reliable.

Ex.

<?php
$spiderSearch = array(
        "GoogleBot"=>"Googlebot",
        "MsnBot"=>"msnbot",
        "Yahoo! Slurp"=>"Slurp",
        "YahooSeeker"=>"YahooSeeker"
        //more search terms from
        //http://www.useragentstring.com/pages/Crawlerlist/
);

$isSpider = false;
foreach($spiderSearch as $name=>$val){
    if(preg_match('/'.$val.'/i',$_SERVER['HTTP_USER_AGENT'])){
        $isSpider = true;
        break;
    }
}

if(!$isSpider){
    //SHOW COMMENTS
}
?>


Filter user-agent or use robot.txt


You can use iframe for hiding content, iframe content can be something like :

<html>
  <head>
    <meta name="robots" content="noindex, nofollow" />
  </head>
  <body>
  <p> This is my content </p>
  </body>  

  </html>


just out of curiosity, why would you want to hid comments? comment posts usually related to what you've write and it will increase the keyword naturally in that page hence increase your keywords optimization. my apology if my comment is out of topic :)

in my knowledge you can use iframe to avoid any indexing by crawlers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜