Stop indexing drupal reply comment pages

From snippet wiki
Jump to: navigation, search

If google indexes every content node twice, one time the goog one and additionally the comment creation url, just enter this into your themes template.php

function YOURTHEME_preprocess_html(&$vars) {
...
  if(false !== strpos(current_path(), 'comment/reply')) {
    $myelement = array(
      '#tag' => 'meta',
      '#attributes' => array(
        'name' => 'robots',
        'content' => 'noindex,noarchive',
      ),
    );
    drupal_add_html_head($myelement, 'robots');
  } // if
...
} // function

Change the function name to your theme name or just add the if block into an existing preprocess function.

Autoren der Seite / Contributors of the page

» Kai Kretschmann, (google+)