Jump to content

[SOLVED] How to tell search engines to ignore part of HTML?


Recommended Posts

Hello!

 

Please tell me how I can tell the search engines to ignore a block of HTML.

 

I have a login prompt on my website for anyone that isn't logged in, and I want to make the search engines ignore this, so that when you see my site in the search engine, there isn't a big fat "Please log in below" at the top of every result.

I think Azu means getting bots to ignore parts of A PARTICULAR page.

 

Azu - you will need to wrap the section in javascript, perhaps compress the section with javascript or something. Bots and robots etc. ignore javascript (well the googlebot anyways at least).

 

-steve

Thanks, the javascript solution works I think :)

 

I am wandering though, is there a way I can just put a certain tag around the part I want the search engines to ignore, to make them ignore it? If I use the javascript solution, then it will only work in browsers that support javascript and have it enabled. This is bad for people that need screen readers and stuff.

Thanks, I was considering that, but then the spider won't follow the links.

 

I just want it so that the block of text and stuff won't stuff up in the search result.

 

I don't want to prevent it from following links in it though.

 

I'm really stumped x_x

Consider this page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title</title>
</head>
<body>

<div>Everybody can see this.</div>

<?php
$bots = array('googlebot'); // i can't remember what the other ones are called
if(!in_array($_SERVER['HTTP_USER_AGENT'], $bots))
{
echo <<<EOF
<div>You are not a known bot so you are allowed to view this as well.</div>
EOF;
}
?>

<div>Everybody can see this as well.</div>

</body>
</html>

 

In that way you can control what the bots should and shouldn't see (i.e. "blocking" text).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title</title>
</head>
<body>

<div>Everybody can see this.</div>

<?php
$bots = array('googlebot'); // i can't remember what the other ones are called
if(!in_array($_SERVER['HTTP_USER_AGENT'], $bots))
{
// Don't display this to bots
echo <<<EOF
<div>You are not a known bot so you are allowed to view this as well.</div>
EOF;
}
else {
// display this to known bots only
echo <<<EOF
<div style='display:none;'><a href='http://example.com/page1.php>text here</a> <a href='http://example.com/page2.php'>other text here</a></div>
EOF;
}
?>

<div>Everybody can see this as well.</div>

</body>
</html>

 

Be careful with that though. You'll risk getting banned because it can look suspicious to a bot if you have a hidden div with a lot of links. I believe this is what is called "Cloaking".

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.