Duplicate Content Issue in K2 [Solved]

in All About Joomla

Final solution of K2 duplicate content issue in webmaster tools. Don’t miss it if you are crying after getting duplicate content using k2 we have finally got a free solution for this most famous mess.


Alright guys you have spent tons of your time building a blog using K2 and now reading these lines after getting duplicate content title / meta description in webmaster tools. Don’t worry I have got the fish for you:) so without wasting time just be on the topic.


First of all let me tell you straight that there are three types of solutions currently rolling out on internet and here they are one by one…

The first one

is adding canonical link in each post of k2 in head section. The only lonely plugin which can work for k2 is Sourcerer but it has some draw backs like:


1. You need to add canonical link manually on each article.

2. Code is displayed in an annoying way in every article when you open it from back end.

3. Its not a guarantee that it will work at any case. This plugin fails often to perform as it says and you get your canonical link of first post in all of your posts.

4. To get it work properly you need to buy pro version which costs 49 Euro.

Anyways you should give free version a try and see you can handle it or not. Here is a safe way to build canonical links in a professional way.

Create an Extra Field Group and Canonical Extra Field

You should first create and assign an appropriate extra fields group and an extra field to your category. You can read about general K2 extra fields use here: K2 Extra Fields. Make sure that extra fields is set to visible for your items!

Now install Sourcerer and add your canonical links in extra field of every article which you have just created. By creating extra field you are simply trying to make it little bit dynamic although you will need to enter each article’s canonical link by hand but in case of rolling it back or when you will get some real good extension for making links canonical in real time you can simply remove your extra field and voila you will get rid of it in a sudden and most important you will not see that annoying link code every time after opening your articles. I am still surprised why developer is not thinking in this direction:).

You will also need to edit extra field’s CSS…Not a big deal man! just set font size to 0px; in k2.css:). No worries at all if you are using Firebug.

Second solution

is using sh404sef for K2 but it is too much complicated and its not an easy game to play with it online. You can get into a big mess trying this most famous sef plugin for K2. In my opinion if you are advance in SEO then there is no reason to not using it. This extension is commercial.


Now the final third free solution to get rid of duplicate content in K2.

Here it is… First of all keep it in mind that unfortunately K2 is not able to solve this issue I will show you why they are not working on this problem but first get the solution.


Alright take your blog’s backup using akeeba free backup plugin. Don’t tell me you are not using akeeba:).


Follow these instructions:

For an item:
take the file: components/com_k2/templates/default/item.php from your K2 template. Add

if ($this->item->link!= JRequest::getURI()) JApplication::redirect($this->item->link,, ,true);

For a category:
take the file
components/com_k2/templates/default/category_item.php from your K2 template. Add

$this->original_link = JRoute::_(K2HelperRoute::getCategoryRoute(JRequest::getVar(‘id’),
if (JRequest::getInt(‘start’) > 0) $this->original_link .= “?start=” . JRequest::getVar(‘start’);
$this->real_link = JRequest::getURI();
if ($this->original_link != $this->real_link) JApplication::redirect($this->original_link,, ,true);

The hack will redirect all duplicated urls to the single right one.


Use at your own risk and remember:

with this hack no parameter can be pushed with any url. Your print pages etc will not work anymore (print page will be loaded WITH template). I couldn’t use multiple categories in menu. Returned a 404 error, so I had to remove the categories hack at least.


Install Xmap Site Map Generator

Xmap is a Site map generator component for Joomla. Xmap allows you to create a map of your site using the structure of your menus. Its a free plugin. Create your site map. This works brilliantly except that the URL generated is always incorrect, it shows using the default component path like this “/component/k2/item/86-my-k2-article”.

Here is quick fix that will show the correct category and path for you.


Navigate to your XMAP K2 Extenstion folder, mine was located at “public_html/plugins/xmap/com_k2” and edit the file “com_k2.php”.


Line 317, show below should be changed from


$node->link = ‘index.php?option=com_k2&view=itemlist&task=category&id=’.$row->id.’:’.$row->alias;


$node->link = ‘index.php?option=com_k2&view=itemlist&task=category&id=’.$row->id.’:’.$row->alias . ‘&Itemid=’ .$parent->id;


to fix the category items. finally change the line 323 from


$node->link = ‘index.php?option=com_k2&view=item&id=’.$row->id.’:’.$row->alias;


$node->link = ‘index.php?option=com_k2&view=item&id=’.$row->id.’:’.$row->alias . ‘&Itemid=’ .$parent->id;


You are simply adding:

. ‘&Itemid=’ .$parent->id;

on to the end of each one of these lines. That will solve your URL problem.


Now here we go for the trick. If you are getting lot of duplicate content errors in webmaster tools then I suggest you to not submit your XML site map there but adding a line in your robots.txt will do the magic.




As soon as your robots.txt will be fetched by google you will see a validation message “Valid sitemap reference detect” that’s all we want:).


Now add one more line to your robots.txt:

Disallow: */itemlist/tag/*


Item listing and tags are very good and important part for your visitors but search engines almost hate these things.


Also remove all meta tags and descriptions from your menus and k2 categories of your blogs only home page menu should be with meta tags others should stay empty with “index Follow”


Follow all of these steps and then wait 10 to 15 days or even more observing your webmaster tools to see how easily you have got rid of this biggest mess created by K2 component. I am personally very surprised to see that in K2 support forum developers don’t bother to reply while thousands of users are crying on this issue and asking for help but they are silent and when they speak…They speak strong language.

To see these kind of strong attitude don’t miss these 2 threads:

How to fix K2 duplicate content issue discussed on official K2 Forum.

Joomla.org reviews on K2

BTW I have found another interesting article on this subject which also covers “Item ID and Number in URL” issue of K2 you should must read it but be aware what he is telling is something very disputed as it should slow your page loading speed because in new k2 version they have option to remove item id an dnumber but with a slower database option but the story is tasty and you will enjoy while reading it. How to remove item and item id in k2 url.

Remember all of these solutions can become worst nightmares of your blogging life if you will take them easy in other words you need to see what is suitable for your website’s situation and what is near to your expertise like in my situation I have successfully deployed the first option of canonical links although that was bit tricky but it worked. Some people feel easy working with sh404sef well I am not…


I hope this article will help you a lot. In case of any trouble comment me and I will get back to you.


Leave a Reply

Your email address will not be published.