Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Avoiding Duplicate Title Tags on Pager Pages in Drupal

Parent Feed: 

Google Webmaster Tools includes a tool called content analysis that you find in the Diagnostics section. The content analysis tool reported a suboptimal number of duplicate title tags and meta descriptions for some Drupal sites that I monitor with these tools.

Getting rid of duplicate title tags and meta descriptions caused by the pager is actually quite simple. When using the Meta Tags module with the setting ALL=INDEX,FOLLOW for Default robots meta tag: you can adjust the robots Meta tag in your theme, so that pages that contain the page parameter in the URL are not indexed using the following code snippet in the head section of your page.tpl.php template file.

<?php
if (isset($_GET['page'])) {
   
$head = str_replace('<meta name="robots" content="index,follow" />',
   
'<meta name="robots" content="noindex,follow" />', $head);
}
print
$head;
?>

If you do not use the Meta tags module or another solution to add Meta tags to the head section of your HTML, the robots Meta tag is not contained in your page source. In this case you can simply append this tag to your head variable like that.

<?php
if (isset($_GET['page'])) {
 
$head .= '<meta name="robots" content="noindex,follow" />';
}
print
$head;
?>

Setting the robots Meta tag to noindex,follow tells search engine crawlers that care about the robots Meta tag and the robots exclusion standard to not index these pages, i.e. they won't appear in search engine results but linked pages will be crawled, provided they are not linked with rel="nofollow".

Adding this code to your theme is a quick hack and not the optimal solution, because it is not easily reusable. Since I want to get rid of this in my theme sometime in the future, I added a feature request to the Meta tags module with a patch that resolves issues with duplicate title tags and meta descriptions on pages generated by Drupal's pager.

The fact that Google displays such issues in the diagnostics section of their webmaster tools indicates that they play a role in evaluating the quality of your site. It is not likely that your site will be considered spam and get banned because of these issues, but it is certainly better to get rid of them.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web