The Code Cave

November 7, 2007

Eliminating duplicate WordPress content in Google

Filed under: WordPress, b5media — Brian @ 3:44 pm

If you are at WordCamp 2007, one of the best sessions was Google’s own Matt Cutts discussion on optimizing your WordPress blog. You can see the whole presentation over on John Pozadzides site’s One Man’s Blog. Here is the link. You can see in Matt’s Whitehat SEO tips for bloggers slide show that one of the things that WordPress “suffers from” is that you can reach the same data from multiple sources.

You can get to the same article by browsing by category, by day, month, year etc. etc. etc. Each time Google sees the same data repeated on your site again, it hurts your site a little bit more.

This bit of code will help fix it. It goes into the header part of your blog and will tell Google that it should ignore all of the pages that are not the orginal source of the article.

Here you go:

PHP:
  1. <?php
  2.   if (is_home() ¦¦ is_singular)
  3.   {
  4.     echo ‘<meta name="robots" content="index,follow">’;
  5.   }
  6. else
  7.   {
  8.     echo ‘<meta name="robots" content="noindex,follow">’;
  9.   }
  10. ?>

11 Comments »

  1. Brian - I don't understand how to use this. What an I missing?

    Comment by Kevin — November 7, 2007 @ 10:27 pm

  2. Great post Brian. I will definitely plug it into my blog.

    @Kevin - basically what the code does is tell the visiting google bots to only consider and index the actual post. If the bot found this post via the categories link or any other way through your blog, then you are kindly asking the google bot to not index it and hence hurt your ranking.

    Just plug it into your header.php

    Comment by John Motson — November 21, 2007 @ 10:44 am

  3. @John - thanks for the input. What I was missing was how to format the code and it looks like Brian updated the post with that since my comment. Now I should be able to get it to work.

    Comment by Kevin — November 21, 2007 @ 12:18 pm

  4. Ah cool, sorry about that

    Comment by John Motson — November 21, 2007 @ 1:30 pm

  5. John - I'm glad you said something - I hadn't noticed the update to the post until your comment. Thanks.

    Comment by Kevin — November 21, 2007 @ 1:58 pm

  6. Sorry Kevin, I'd typed up a comment just so that you would be notified. I even went out to visit your site after I typed it up. I must have gotten so caught up in one of your posts that I forgot to hit "post comment" back here... Anyway, glad it makes sense now...

    Comment by Brian — November 21, 2007 @ 2:58 pm

  7. No problem Brian - I thought it was a little strange you hadn't replied to my comment but forgot about it and didn't come back to the post.

    I've tried it temporarily on one of my sites and I'm not seeing any of the page headers show "noindex" only "index". Shouldn't it be showing the "noindex" on the category, month and years pages, etc.? Or am I not understanding how it works?

    Comment by Kevin — November 21, 2007 @ 3:10 pm

  8. Yes it should, did you have any caching installed on those pages?

    Comment by Brian — November 30, 2007 @ 4:03 pm

  9. No Brian - no caching was being used.

    Comment by Kevin — November 30, 2007 @ 4:15 pm

  10. Hey Brian great tip.
    Ok maybe I'm just a dummy ( actually thats a foregone conclusion) But when I put that in my header.php I keep getting a parse error. I dont expect support but Could you , when you have the time maybe clarify where in the header, ive looked at how some of the php code is formatted and tried to duplicate to no avail
    Cheers and Beers
    Shane

    Comment by shane — December 30, 2007 @ 6:17 pm

  11. I have been visiting this site a lot lately, so i thought it is a good idea to show my appreciation with a comment.

    Thanks,
    Jim Mirkalami

    Comment by Jim Mirkalami — February 8, 2008 @ 6:33 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress