Bug #88545


Epic #89797: HrefLang / Canonical issues

Behaviour canonical link and HTML lang tag in language overlay

Added by Altan Tosun about 5 years ago. Updated over 3 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:
On Location Sprint


If you on a non-translated alternative language page and the fallback language page is shown, the HTML lang tag provides the wrong language code. It provides the code of the chosen language but it what is actually should provide is the code of the overlay language. For example if you are on a non-translated EN page the fallback language DE is shown. In this case the HTML lang tag should be DE but and not EN.

Second, the canonical link points to the path of the EN page like /en/blablabla which delivers the same content like /de/blablabla which is duplicated content. To solve this problem the canonical link of the non-translated page should point to the URL of the fallback/original page.

TYPO3 version: 9.5.7


ext_localconf.php (489 Bytes) ext_localconf.php ./ext_localconf.php Benjamin Serfhos, 2020-05-04 10:46
LanguageFallbackCanonicalGenerator.php (2.53 KB) LanguageFallbackCanonicalGenerator.php ./Classes/Canonical/LanguageFallbackCanonicalGenerator.php Benjamin Serfhos, 2020-05-04 10:46

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #89462: hreflang missing for languages with fallbackType: fallbackClosed2019-10-21

Related to TYPO3 Core - Bug #88020: inconsistencies in hreflang outputClosed2019-03-27

Actions #1

Updated by Richard Haeser almost 5 years ago

  • Status changed from New to Needs Feedback

Hi Altan,

Thanks for your report. For my information. How is your setup and situation? I just tried and could only get this (when:

- Language mode is fallback
- Default language is set as fallback
- There is a page record for default language and for alternative language
- Content in default language and no content in alternative language

So we have a page record but no content for that page. You can set all page properties of the alternative language. You can even decide that you have content for specific colPosses, but not for all. So only empty columns will have a fallback. It is very hard to decide which language code and canonical you need to set in those situations.

How do you see this? When do we set the canonical and language to the fallback language?

Actions #2

Updated by Richard Haeser over 4 years ago

  • Related to Bug #89462: hreflang missing for languages with fallbackType: fallback added
Actions #3

Updated by Richard Haeser over 4 years ago

  • Related to Bug #88020: inconsistencies in hreflang output added
Actions #4

Updated by Richard Haeser over 4 years ago

  • Parent task set to #89797
Actions #5

Updated by Susanne Moog over 4 years ago

  • Sprint Focus set to On Location Sprint

Updated by Benjamin Serfhos about 4 years ago

I locally fixed this in the beforeGeneratingCanonical signal using the following code in the attached zip.
This function checks if the displayed language content differs from the selected language. If so, writes the canonical url.

It could be directly in CanonicalGenerator as:

     * @param  string  $href
     * @return array
    public function checkForActiveLanguageFallback(string &$href): array
        $languageId = $this->languageAspect->getId();
        if ($languageId > 0 && $this->languageAspect->getContentId() !== $languageId) {
            return $this->typoScriptFrontendController->cObj->typoLink_URL([
                'parameter' => $this->typoScriptFrontendController->id . ',' . $this->typoScriptFrontendController->type,
                'forceAbsoluteUrl' => true,
                'additionalParams' => '&L=' . $this->languageAspect->getContentId(),
                'addQueryString' => true,
                'addQueryString.' => [
                    'method' => 'GET',
                    'exclude' => implode(

        return '';

Actions #7

Updated by Richard Haeser over 3 years ago

  • Status changed from Needs Feedback to Closed

With a hreflang tag is rendered for fallback languages even when no page record is translated. This makes sure those pages are not marked as duplicate content. This way you don't have nasty conditions to check if a page has translated content on it etc. If you want to alter the defined hreflang tags, you can use the ModifyHrefLangTagsEvent. See for more information in 10.4. In version 9, you can disable the automatic hreflang tag generation and use your own implementation. For 9.5 you can find more information on


Also available in: Atom PDF