T3SEO

TYPO3 and SEO since 2011

Canonical Tag and TYPO3

The canonical tag is probably the most underestimated SEO method around, though it should be present on any website. Learn why the canonical tag is so important, how to use it and what must be considered when using TYPO3.

Objectives of the canonical tag

The canonical tag provides the official URL for the content shown on the page. Sounds trivial - the client already did call the page with its URL, didn't it? Unfortunatelly this is not always the case. Almost on every website there are contents that can be called by using multiple URLs, which leads to duplicate content. Here are some examples how such situations can occur:

Creation of dirty URLs

You can see this case quite often: A page is linked from within the site by a dirty URL. In combination with TYPO3 this can occur when a link is not parsed by typolink(), realurl is misconfigured or if you use certain shortcuts in the pagetree.
Normally those mistakes can be avoided if you work properly. However if you are in this situation, the canonical tag can save you from the worst.

Pagebrowsers, Sorting, Categorization

When records are presented often Pagebrowsers, Sorting, Categorization or other mechanisms are involved which lead to the fact that equal or similar contents are available under different URLs.
A classical issue is a product's details page, where the category appears in the URL. When there are more than one category for the product, there will probably be more than one URL pointing to the same details page.

Dirty links from outside

If you have plugins like a poll on your website those often happen to append parameters like ?voted=1 to the URL when used. The user could take this URL and link to it or tweet or bookmark it, which then can take that URL into the Google index - of course another case of duplicate content.
And finally you have to consider tracking and affiliate parameters, malicious links with superfluous parameters or any other broken links from any external system.
Obviously you can't eliminate those links, but the canonical tag can defang them.

There certainly are plenty more things to tell about duplicate content, but that was already done by others. At least it's becoming clear that everybody building websites should think about this topic.

Using the canonical tag with TYPO3

Given a simple TYPO3 website without any plugins the configuration of canonical tags is quite easy:

page.headerData.1422 = TEXT
page.headerData.1422 {
    stdWrap.typolink.parameter.data = TSFE:id
    stdWrap.typolink.forceAbsoluteUrl = 1
    stdWrap.typolink.returnLast = url
    htmlSpecialChars = 1
    wrap = <link href="|" rel="canonical" />
}

A canonical tag with a link to the current TYPO3 page is generated. This even works with multi-language websites instantly if you have set config.linkVars = L.

URLs for details pages

However using tt_news or similar extensions with records with the above snippet will result in all details pages having the same broken URL (like example.com/news/detail/­), because important GET parameters were truncated. To add these you must not use the seemingly convenient option typolink.addQueryString = 1, because it will add all given GET parameters to the canonical URL, even those that are not supposed to be there. Instead you have the to configure the needed parameters separately:

page.headerData.1422 = TEXT
page.headerData.1422 {
    typolink.parameter.data = TSFE:id
    typolink.forceAbsoluteUrl = 1
    typolink.returnLast = url
    typolink.additionalParams.cObject = COA
    typolink.additionalParams.cObject {
        10 = TEXT
        10.dataWrap = &tx_ttnews[tt_news]={GP:tx_ttnews|tt_news}
        10.if.isTrue.data = GP:tx_ttnews|tt_news
        20 = TEXT
        20.dataWrap = &tx_ttnews[cat]={GP:tx_ttnews|cat}
        20.if.isTrue.data = GP:tx_ttnews|cat
    }
    wrap = <link href="|" rel="canonical">
}

In this case the GET parameters tx_ttnews[tt_news] and tx_ttnews[cat] are added if they are given. What parameters exactly belong to your canonical tag depends on what extensions you are using and how they are configured. In any case you have to test the generated tags carefully. A mistake may result in many pages that are not indexed.

Mount points and "Show Content from Page"

If there is duplicate content as a result from using mount points or the "Show Content from Page" feature, the canonical extension by Georg Ringer may help you. Unfortunatelly the extension will only generate a canonical tag in this specific cases and thus is not compatible with the above snippet. If you used both together you might end up having two canonical tags. But if you only use the canonical extension it will only help you in this rare cases and you are not protected from all the other types of duplicate content. Maybe there will be a more advanced version of the extension some day that produces a valid canonical tag every time a page is generated.

Conclusion

I hope I made clear that every website that is being built deserves a moment to think about the usage of canonical tags. There are no hard and fast rules that would fit for all TYPO3 installations, but I showed you the ways to go.

Finally I have to add that 301 redirects are still neccessary to fight duplicate content, especially in predictable cases like "slash at the end of the URL" or "begin the URL with or without www".

Picture Credits: juice by (matt) (CC BY-ND 2.0)

Canonical Tag and TYPO3

    Related Topics