Prevent Googlebot from indexing certain parts of a Drupal page

  • 21 Jul 2012
  • Drupal, SEO

In this Drupal site, I show my lastest tweets using this module. Works great, but now I want to prevent Google to index my tweets.

Reading this post of 2007 I found the light at the end of the tunnel:

Come to the fair!

"The text Come to the fair! is not indexed, is not associated with anchor text, and does not appear in snippets with the search results."

Now, to put this code (or this comments) into my site, I have to hack the theme of the view generated by the Tweeter module.

The workaround

1. Go to admin/structure/views/view/tweets/edit

2. Click on Advanced -> Theme -> Information

3. Copy the last file name from "Display output". In this case: views-view--tweets--page.tpl.php

4. Click on "Display output" and copy the code shown

5. Create the file in your templates folder and paste the copied code

6. Add <!--googleoff: all--> to the beginning of the file and <!--googleon: all--> at end

Note: If the part of site in question is a block, you can modify the template file page.tpl.php to obtain the same result!