Bug #88545

Epic #89797: HrefLang / Canonical issues

Behaviour canonical link and HTML lang tag in language overlay

Added by Altan Tosun over 1 year ago. Updated 7 months ago.

Needs Feedback
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

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

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


Updated by Richard Haeser over 1 year 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?


Updated by Richard Haeser almost 1 year ago

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

Updated by Richard Haeser almost 1 year ago

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

Updated by Richard Haeser almost 1 year ago

  • Parent task set to #89797

Updated by Susanne Moog 11 months ago

  • Sprint Focus set to On Location Sprint

Updated by Benjamin Serfhos 7 months 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 '';

Also available in: Atom PDF