How To: Solve duplicate content in WordPress without plugins

ADVERTISEMENT
To get our software and web/tips via email, sign up for daily email newsletter.
Subscribe to RSS feed or follow me on Twitter?

Duplicate content is a serious issue for all WordPress blogs, and most bloggers now employ different methods to show partial content. The only blogs with good search rankings which employ full posts, are usually authority blogs, which are labelled as safe and authoritative by Google’s algorithm.

Plugins are a popular method to reduce duplicate content. However, plugins are not fully optimized, and consumes more server resources than the simple <?php the_excerpt() ?> tag. Moreover, excerpt tag can use the customized post summary that you may have written.

In this short tutorial, you should have all the template files in one place. Once you have those files(probably downloaded from your server, or a local copy that you keep), follow these easy steps:

ADVERTISEMENT

  • Open up index.php, archive.php and search.php
  • In each of these files, search and find the code bit that contains <php the_content
  • Replace the entire tag – usually <?php the_content(__(’Read the rest of this entry’));?> (may change depending on theme, but will be similar), with this tag:
    <?php the_excerpt();?>
    Save the files.
  • Open up index.php again, and save it as category.php (do not discard index.php).

In the above steps, we have replaced the content tag with the excerpt tag so that only a short paragraph of the post is shown on pages other than the post page. Most themes lack a category.php, and its absence can allow full posts on category pages. By duplicating the index.php file(which has excerpt tag), that problem is also solved.

Open Mic

How do you prevent duplicate content? Do you use this method, or any plugins? If so, why do you prefer it over the excerpt tag?(I’d like to hear, as I am myself confused at which method to choose). Do tell me your views through comments.

Comments
  1. This is exactly what I have been doing. Use post excerpts.

    Nirmal
  2. @Nirmal: Glad to hear your opinion. Could you be more specific as to why you prefer it?

    Sumesh
  3. Funny to run into this, I’d just blogged about something similar yesterday! And you did this 2 days earlier – guess it was a repeat for you to read my feed then!
    [Goes over to subscribe to your feed]

    But I’d just like to make one clarification though – you won’t need category.php if you have archive.php or index.php (err, you’d certainly have this one!). What I meant was – if you are going to show excerpts on index.php, you can avoid having archive.php and category.php altogether – don’t ask me why not, saves you 4kb on your webspace ;)

    The order is:
    1. category-xx.php
    2. category.php
    3. archive.php
    4. index.php

    If you’d like to make one particular category look unique, you can create a file with the category-CATEGORYNUMBER.php and that particular category would follow this template. If it doesn’t find this file, it will check if the next file in the hierarchy is there and so on.

    Sorry about the overly long comment, I had to make myself clear!

    Karthik
  4. @Karthik: No problem whatsoever about long comments – I love ‘em!
    Well, that thing about category-xx.php was something new to me, thanks. And category no. means its ID, right?
    As for 4kB webspace, lol :D

    Sumesh
  5. Yup, sorry, I should have mentioned ID there!

    Karthik
  6. @Karthik: No problem, its understood. Now that you’ve clarified it, readers will also understand.

    Sumesh
  7. My recommendation would be to do this but also have unique content in the excerpt.

    I have actually switched categories off entirely and have opted for pages instead.

    (Note the blog above is not an example of this ;-D )

    Fred Schebesta
Leave a Reply

If you have a computer/web help question, click here to ask it on our forum for faster response.