WordPress: The Art of Avoiding Duplicate Content

by Dev Duff on April 27, 2009

We all know ‘Content Is King’. However, whoever said that, meant to say: ‘Unique Content Is King’. Putting together a beautiful website/blog is just the first step to your ebusiness. The more important part is to put together ‘unique content’ and avoid the duplication by following simple steps. This article is for those bloggers/webmasters who wish to avoid getting penalized for duplicate content, by Search Engines. After reading this article, you will master the art of avoiding duplicate content in your self-hosted WordPress Blog and this will help you in getting higher rankings on search engines by following simple easy techniques.

Lately, I researched on avoiding duplicate content and found some very interesting facts about avoiding duplicate content in WordPress, by changing few easy codes. I found that using excerpts is by far one of the best practices to avoid duplicate content.

To get into depth and understand what are excerpts, you should read the WordPress codex: Excerpt and understand what are excerpts and how they can be helpful. In layman language, WordPress Excerpts are summary of the actual posts which gives the user an idea about ‘what is being discussed in an article’. In-detail knowledge of the function the_excerpt can be found at WordPress Codex: Template Tags/the excerpt.


To effectively use excerpts in WordPress, you need to optimize the code of Index Page (index.php), Archives Page (archives.php), Category Page and Search Results page. The idea is to stay focused to the Single Post (single.php). Which means, the complete post or article should be visible only on the Single Post page. All other pages should show only the excerpt/summary of the article(s).

I’m using the Amazing Grace theme designed by Vladimir Prelovac, so I will take it as an example and describe how to use the_excerpt() function and avoid content duplication. However, by understanding the actual code, you can apply this on any given WordPress theme. If you look at the actual Index Page (index.php) of the Amazing Grace theme, you will see this code (Please note, in the original theme, the excerpts have been configured for only Archive Pages and Search Results Pages) in the source:

<div class="entrybody">
<?php if (is_archive() || is_search()) : ?>
<?php the_excerpt(); _e('<p><a href="'.get_permalink().'">
Continue reading about '); the_title(); _e('</a></p>');  ?>
<?php else : ?>
<?php the_content('Read the rest of this entry »');   ?>
<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
<?php endif; ?>

In the above code, you can see, the excerpts have been configured for only Archive Page and Search Results Page. However, we want to have complete posts only for Single Post pages and all the other pages should show just the excerpt/summary. So, I configured the code as follows:

<div class="entrybody">
	<?php if (is_singular()) : ?>
	<?php the_content();  ?>
	<?php else : ?>
	<?php the_excerpt(); _e('<p><a href="'.get_permalink().'">
Continue reading about '); the_title(); _e('</a></p>'); ?>
	<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
	<?php endif; ?>

You can compare the two codes mentioned above and understand that in the new code, We have used the_content() for ONLY Singular Posts (The actual Post Pages). And we have used the_excerpt() for all other pages. Doing this will ensure that the complete post appears only on the actual Post Pages and no where else. To describe the code a bit more, I’m including some further information:

<div class="entrybody">	   //Starting of code.
	<?php if (is_singular()) : ?>	//Starting of 'if statement.
	<?php the_content();  ?>    //Show complete content.
	<?php else : ?>    //The 'else' statement.
	<?php the_excerpt(); _e('<p><a href="'.get_permalink().'">
Continue reading about '); the_title(); _e('</a></p>'); ?>  //Show excerpt.
	<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>   //Show tags of post.
	<?php endif; ?>		//Ending of code.

Since, Amazing Grace and Blue Grace (Both designed by Vladimir Prelovac) have been wonderfully coded, it is easy to tweak the code to avoid content duplication, however, similar tweaks can be done on any given theme and master the art of providing unique content to Search Engines.

If you are using a different theme, please feel free to ask me questions. I will be glad to tweak the code for you. If you have any better tips to resolve the ‘wordpress duplicate content’ issue, please feel free to post a comment below. You can explore other wordpress tutorials that may interest you or help you in one way or the other.
Thankyou for reading this article!

This post was written by...

– who has written 305 posts on Dev Duff.

Contact the author

{ 6 comments… read them below or add one }

Miss L.

Thank you so much for posting about avoiding duplicate content. I am new to using WordPress and have very limited knowledge of editing php code. I love the Amazing Grace theme you referred to but thought I was going to have to change themes. I just couldn’t figure out what part of the php code I needed to change regarding excerpt. Your examples shown above and explanation was very helpful to correcting the problem I was having.

Great job and thanks again for such a detailed explanation. Now, I’ll know how to correct this with any WordPress theme I decide to work with.


Dev Duff

I’m glad to know that the article was helpful. Thanks for the kind words :)
Your comment is full of motivation, I will share more experiences in the upcoming posts.



I have an iphone 3G, and I have lots songs in my iphone, because it is synced with my computer(iTunes), what if I bought a new computer, how do you keep your old songs in your iphone? Or shall I say would you be able to sync your iphone with a new computer without losing any old songs? Many thanks!


Andrew Keir

Hi DevDuff,

I have 1 little tweak on this that I wan’t to implement, I wonder if you can help.

At the moment my blog is using the_content, and I would like to change this to an excerpt. I have a few hundred posts without excerpts so it will obviously take some time to do.

I’m not terribly familiar with the if and else usages. What I’d like to do is if an excerpt exists, show it, else show the_content and use the existing more tag.

This was I can add excerpts over the next few weeks while immediately reaping the benefits on updated posts. I hope that makes sense… Thanks in advance for any advice.


Dev Duff

Hello Andrew,

First of all, really sorry for responding so late.

About the question(s) you asked, there are couple of things you can do. If you simply replace the_content() with the_excerpt() in the Main Index Template (index.php) file in your theme, it will automatically show the excerpt of your posts. If you do not provide any excerpt within your articles, it doesn’t matter. Wordpress will automatically pickup the first paragraph of your article and display an excerpt.

Now, to beautify or customize your “excerpt”, there are couple of things you can do:
1). You may use this article to edit your theme: http://codex.wordpress.org/Function_Reference/the_excerpt
2). You can use a plugin that can help you customize the way excerpts display on the homepage.

About this specific question: “I’m not terribly familiar with the if and else usages. What I’d like to do is if an excerpt exists, show it, else show the_content and use the existing more tag.”

Answer: Wordpress will handle this by default. If you provide an excerpt within each article, Wordpress will display it. If you do not provide an excerpt within your articles, Wordpress will automatically display the first paragraph of your article. So all in all, you have to just change the_content() to the_excerpt(). Job done!

I hope I was able to assist you. If not, please feel free to ask questions. I will be happy to assist you.


Andrew Keir

Hi Dev,

I’ve got the excerpt function working as intended now, still havn’t quite got the if/else going though… It’s ok though, I’d best spend the time writing the 260 excerpts and just swapping it over instead of mucking around with my php.

Thanks for the advice and help links.


Leave a Comment

Previous post:

Next post: