How to Avoid Duplicate Content in WordPress

Duplicate content is one of the common mistakes of new WordPress sites and it can be easily fixed with these simple tricks.

What is duplicate content briefly?

Duplicate Content is detected by search engines when your site contains one or more pages with identical urls, titles, descriptions or content. What is considered to be poor quality content and penalizes the ranking of your web pages in search engines.

However, this does not mean that some text contents can not be reused in several pages. There are exceptions as it is the case with online stores and product catalogs which contain a lot of repetitive and similar content to their competitors. There is not only one car dealer who is selling Ford, GM or Toyota cars. What is important is that each page be unique and original.

Duplicate content in WordPress

WordPress is a powerful tool for SEO but when misconfigured it can become the worst enemy of search engines. One of the common problems with WordPress occurs when you enable blog features and start publishing articles and grouping them into categories, which is highly recommended and appreciated by search engines. However, by doing so, it then becomes available via two links rather than just one.

For example, if an article is published with the following link: http://mysite.xyz/cheezecake/ and added to a category called recipes it will then also be available under the http://mysite.xyz/category/recipes/ link, which contains a list of all your recipe articles with their respective titles and texts. What is automatically considered duplicate content by search engines.

How to fix duplicate content in WordPress

To fix this issue, simply add the following code in the HTML header of each category pages:

<meta name="robots" content="noindex,follow"/>

This code is exclusively reserved to search engines. Next time a search engine robot visit your category page, it will find this instruction that will tell it to NOT index your category page which contains a copy of your article titles and excerpts.

PHP code to fix duplicate content in WordPress

Here's the PHP code to fix duplicate content issues with your WordPress categories only. Simply copy and paste this PHP code into the functions.php file of your WordPress theme.

functions.php
wp_enqueue_scripts wp_head the_post

PHP Code Features

  • INIT Action: We inject the code into the WordPress wp_head action hook, which is specifically reserved for adding content to the HTML header of the web page.
  • Anonymous Function: By using an anonymous function rather than a named function, we save memory in the Global Namespace, which is already heavily loaded by WordPress and third-party plugins. Read my article How to disable Emojis in WordPress for more details about this personal twist.
  • PHP Memory Release: Finally, we use the PHP unset($af) instruction to free out memory from the dynamically created anonymous function. Read my article How to disable Emojis in WordPress for more details.

Disable duplicate content with one click

The high-performance WordPress theme Apace allows you avoid duplicate content with a single mouse click, along with several other SEO settings for WordPress. See image below:

Comments