Using noindex Meta Tag in WordPress to Prevent Search Engines Indexing Categories, Tags and Archives

WordPress may show “duplicate” content which may potentially confuse search engines. Duplicate content won’t hurt much, unless it is spam or keyword stuffing, as said by Matt Cutts, and Google may just ignore the duplicate content. However, instead of letting the search engines decide which pages of the duplicate ones are important, we may only want the search engine to index those important ones such as the posts and pages, instead of those less important ones such as categories, tags or archives.

A noindex meta tag will prevent search engine such as google from indexing the page. Google’s rule about noindex tag is like (ref):

When Googlebot next crawls that page and sees the tag or header, Googlebot will drop that page entirely from Google Search results, regardless of whether other sites link to it. … Using noindex is useful if you don’t have root access to your server, as it allows you to control access to your site on a page-by-page basis.

We can add noindex tag to the head of archives, categories, tags and search results in WordPress.

The method is simple. First find the header.php file in the theme directory. Then insert these codes into the area between <head> and </head>:

<?php
// Do not index author, date archive, category, tag and search result
if( is_author() | is_date() | is_search() | is_category() | is_tag() ) {
  _e('<meta name="robots" content="noindex,follow" />');
}
?>

If you would like search engines to index some pages, such as the categories, you may delete the relevant is_… functions such as is_category().

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

5 comments:

  1. Exactly what we were looking for. Btw, I think it’s header.php not head.php :)

  2. That’s really a very simple solution to No index tags and categories. But if you are using Yoast plugin you may configure it to no index the tags and categories.

  3. Pingback: What is a better solution of doing SEO for WordPress than using a dedicated plugin? - OlivianBreda.com
Leave a Reply

Your email address will not be published. Required fields are marked *