Post Pic

How to: avoid duplicate content in your WordPress blog

Duplicate content is often a problem with WordPress blog, and as you probably know it, it can hurt your blog SEO. Here is a small code to insert on your header.php file, to get rid of duplicate content in your WordPress blog.

Simply paste theses line between the <head> and </head> tags in your header.php file.

<?php if((is_home() && ($paged < 2 )) || is_single() || is_page() || is_category()){
    echo '<meta name="robots" content="index,follow" />';
} else {
    echo '<meta name="robots" content="noindex,follow" />';
}

By using WordPress conditionnal tags, this code ensure that your homepage, posts, pages and category pages are indexed by search engines spiders, but prevent all other pages (feeds, archives, etc) from being indexed and create involuntary duplicate content.

19 Responses

Jan 19 2009 11:04

Why include categories? They are duplicate content and even worse they are dynamic so search enging may point to page X of specific category but post will be pushed on other page by then.

Nice tweak, I use robots.txt but this might be even more foolproof.

Jan 19 2009 12:05

if( is_home() && !is_paged() || is_singular()) { …}

@Rarst: right!

Jan 19 2009 13:50

I added the code to my WP 2.2 blog but I get an error and my site doesn’t show.

It would be great to use because I am sure I am being hit with duplicate content penalties.

Jan 19 2009 21:38

@Michael: Indeed this is better! I’ll correct the code ASAP.
@James Mann: I don’t know, WP 2.2 is quite old now, so you should consider upgrading :)

Jan 20 2009 03:51

Very cool idea.

Jan 20 2009 07:21

To avoid duplicate content is only by the content itself. Google index our single post to index if it’s duplicate content or not. And we still can use same post but with minimal 30% different words, can be changed with synonim or different paragraph structure.

And, if we use your code, does it effect our meta tag or not?

Jan 20 2009 11:01

Still no help for me.
Yes, I know about the method to let some posts not be indexed manually, but that is very tiring, and it’s not instant. Since whenever a feed updateds and it gets posted on my site, I have to lookup the ID and then add it to the code where it says (that’s from a other receipt).

What I want is something more instant, like telling not to index posts of a specific category.

Jan 20 2009 23:42

Why exactly is there a $paged < 2 in the code ? We would also want to index/follow page 3,4,5,6…. or am I missing something ?

Jan 21 2009 00:10

Or just use the WordPress plugin wpSEO :) at http://wpseo.org

Jan 21 2009 12:22

@bloginstall

No, such pages should not be indexed.

You only want indexed:
-home page
-static pages (archives, etc)
-single post pages

Jan 21 2009 13:00

Opps, did not see the is_category() tage in the code ;) Thanks.

Jan 21 2009 13:05

No sure how google handles the post links that move from one index page to another …. any thoughts on this ?

Feb 02 2009 20:24

In regards to the duplicate content part of this blog post, I personally use the http://www.copygator.com website to find and stop duplicate content:

1. it’s automated and brings me results instead of me searching for duplicated content. All i had to do was submit my feed and it started monitoring my feed showing me who’s republished my articles on the web.

2. i get notified by email so it contacts me when it finds copies of my articles online.

3. i use their image badge feature to alert me directly on my website when my content is being lifted.

4. it’s a free service as opposed the “per page” cost of copyscape/copysentry.

Mar 23 2009 06:00

I always blocked my categories in my robots and allowed the tags, is that wrong? I thought categories were also dupe content?

Sep 13 2009 21:55

I will use this code on one of my blogs. I have also found some useful links in the posts above.

Sep 16 2009 02:22

Nice little tip! Seo is an integral part of your blog’s success, and you can get easily penalized for duplicate content even though it’s out of unawareness. This is the one thing you have to be careful with wordpress. But again there are many ways to fix it. And the tip mentioned here is just one of them.

Aug 18 2010 18:17

Thanks for the article I’m new to all the SEO stuff for blogs, I thought wordpress might have made it so this was standard in their releases.

Darren.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required