Trying to avoid duplicate content in my blog


After watching video about Canonical link element By Matt Cutts , I analyzed my site for possible duplicate content. I found that there are some pages having duplicate content.

I had listed these pages below:

  1. Article listing based on tags and article detail page. This happens when there is only one article inside a tag.
  2. Article listing based on category and article detail page. This happens when there is only one article inside a category.

I started searching for word press plug-in. One plug-in I found was adding canonical link to page and post. The plug-in was named “No duplicate content”. What it does is adding canonical link element for single page and post.

<link rel="canonical" href="YOUR_PREFERED_URL"/>

For my blog I don’t need a canonical link element in article detail page. There is no chance of duplicate content for article detail page. The only url I am providing to search engines is the permalink of the page.

In category/tag page I found an alternative way to avoid duplicate content. I wrote a small script for permanent redirect (301) in category/tag page. The redirect is conditional the page will be redirected if there is only one post inside category/tag page.

add_action ( "template_redirect", "canonicalLink");
function canonicalLink() {
	global $wp_query;
	$postCount = count($wp_query->posts);
	if((is_category()|| is_tag()) && $postCount==1) {
	 return wp_redirect(get_permalink($wp_query->posts[0]->ID),301);
	}
	return ;
}

I am experimenting with my blog, so I will be checking whether this script have any difference with Google indexing.

  1. #1 by Sunil - March 1st, 2009 at 13:53

    Hi,

    We cant expect the difference in Google’s indexing.. I think it is only a best practice. Lets see :) I already installed wordpress plugin for the canonical issue in my blog myhtmlworld.com

  2. #2 by Nishanth - March 1st, 2009 at 14:52

    @Sunil
    Thanks Sunil,
    What i meant by difference in indexing is to avoid some pages from Google indexes by using 301 redirects.

(will not be published)
  1. No trackbacks yet.