
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.

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.
18 Responses
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.
if( is_home() && !is_paged() || is_singular()) { …}
@Rarst: right!
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.
@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
Very cool idea.
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?
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.
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 ?
Or just use the WordPress plugin wpSEO
at http://wpseo.org
@bloginstall
No, such pages should not be indexed.
You only want indexed:
-home page
-static pages (archives, etc)
-single post pages
Opps, did not see the is_category() tage in the code
Thanks.
No sure how google handles the post links that move from one index page to another …. any thoughts on this ?
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.
I always blocked my categories in my robots and allowed the tags, is that wrong? I thought categories were also dupe content?
I will use this code on one of my blogs. I have also found some useful links in the posts above.
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.
Trackbacks: