joomla/joomla-cms — pull request #3491 by hans2103 (2014-04-22 22:42:08+00:00)
Title: changing implementation of Canonical URL creation

* changing trigger from onAfterRoute to onContentBeforeDisplay (because I need content information for creation of Canonical URL)
* add if-then-else statement for creation of proper Canonical URL for com_content view=article

Reason for this pull request is to solve the wrong Canonical URL for an article. Problem is that Google will index all provided canonical weblinks. You will end up with duplicate content.

examples with com_content and view = article
open an article in a category blog view and look at the created Canonical URL
* http://www.byte.nl/nieuws/2553-byte-op-de-joomladagen-2014
* * canonical url = http://www.byte.nl/nieuws/2553-byte-op-de-joomladagen-2014

add parameters to the URL and take a look at the created Canonical URL
* http://www.byte.nl/nieuws/2553-byte-op-de-joomladagen-2014?utm_source=newsmail&utm_medium=email&utm_campaign=newsmail_2014_03
* * canonical url = http://www.byte.nl/nieuws/2553-byte-op-de-joomladagen-2014?utm_source=newsmail&utm_medium=email&utm_campaign=newsmail_2014_03
* * expected canonical url = http://www.byte.nl/nieuws/2553-byte-op-de-joomladagen-2014

add an extra subcategory in the URL and take a look at the created Canonical URL
* http://www.byte.nl/nieuws/banaan/2553-byte-op-de-joomladagen-2014
* * canonical url = http://www.byte.nl/nieuws?catid=0&id=2553
* * expected canonical url = http://www.byte.nl/nieuws/2553-byte-op-de-joomladagen-2014

remove a part of the URL and take a look at the created Canonical URL
* http://www.byte.nl/nieuws/2553-byte-op-de-joomladagen <- without “-2014″
* * canonical url = http://www.byte.nl/nieuws?catid=2553&id=2553:byte-op-de-joomladagen-2014
* * expected canonical url = http://www.byte.nl/nieuws/2553-byte-op-de-joomladagen-2014

With the patch applied a correct Canonical URL is created.
It will prevent duplicate content.

(On byte.nl I installed a plugin to correct the canonical URL and will remove the plugin once my pull request is merged into core. Feel free to use the plugin in the meanwhile https://github.com/hans2103/plg_system_canonicalurl )