Jump to content

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


Azu

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

Thank you :)

 

Just 1 more little question.. is there a way to make it so that the search engine will still follow links in a block of text, but won't index the block of text?

Link to comment
Share on other sites

<!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".

Link to comment
Share on other sites

Thank you! This is what I am looking for.

And it is just for making my navigation links not show up on all my search results, so I'm pretty sure I won't get in trouble for it.

Link to comment
Share on other sites

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.