Project

General

Profile

Actions

Bug #88703

closed

Generated alternate hreflang urls have not allowed transport method

Added by Markus Gehrig over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
SEO
Target version:
-
Start date:
2019-07-08
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Google wants alternate URLs formatted as followed:

"Alternate URLs must be fully-qualified, including the transport method (http/https), so:
https://example.com/foo, not //example.com/foo or /foo"

(https://support.google.com/webmasters/answer/189077?hl=en)

At the moment TYPO3 generates alternate urls like //example.com/foo.

Our site configuration:

rootPageId: 1
base: '/'
languages:
  -
    title: Deutsch
    enabled: true
    languageId: '0'
    base: /de/
    typo3Language: de
    locale: de_CH.UTF-8
    iso-639-1: de
    navigationTitle: DE
    hreflang: 'de-ch'
    direction: 'ltr'
    flag: de
  -
    title: Italienisch
    enabled: true
    languageId: '3'
    base: /it/
    typo3Language: it
    locale: it_CH.UTF-8
    iso-639-1: it
    navigationTitle: IT
    hreflang: 'it-ch'
    direction: 'ltr'
    fallbackType: strict
    fallbacks: '3'
    flag: it
  -
    title: Englisch
    enabled: true
    languageId: '1'
    base: /en/
    typo3Language: default
    locale: en_GB.UTF-8
    iso-639-1: en
    navigationTitle: EN
    hreflang: 'en-gb'
    direction: 'ltr'
    fallbackType: strict
    fallbacks: '1'
    flag: gb
  -
    title: Französisch
    enabled: true
    languageId: '2'
    base: /fr/
    typo3Language: fr
    locale: fr_CH.UTF-8
    iso-639-1: fr
    navigationTitle: FR
    hreflang: 'fr-ch'
    direction: 'ltr'
    fallbackType: strict
    fallbacks: '2'
    flag: fr
errorHandling: {  }
baseVariants: 
  -
    base: 'http://www.example.local'
    condition: 'applicationContext == "Development"'
  -
    base: 'http://dev.examle.ch'
    condition: 'applicationContext == "Development/Remote"'
  -
    base: 'http://examle.ch'
    condition: 'applicationContext == "Production"'
routes: {  }

Actions #1

Updated by Georg Ringer over 5 years ago

  • Category changed from System/Bootstrap/Configuration to SEO
Actions #2

Updated by Chris Müller over 5 years ago

I can't confirm this. My configuration:

rootPageId: 3
base: 'https://www.example.com/'
baseVariants:
  -
    base: 'https://website.ddev.local/'
    condition: 'applicationContext == "Development"'
  -
    base: 'https://staging.example.com/'
    condition: 'applicationContext == "Production/Staging"'
  -
    base: 'https://testing.example.com/'
    condition: 'applicationContext == "Testing"'
languages:
  -
    title: English
    enabled: true
    languageId: '0'
    base: /en/
    typo3Language: default
    locale: en_US.utf8
    iso-639-1: en
    navigationTitle: English
    hreflang: en
    flag: us
  -
    title: Deutsch
    enabled: true
    languageId: '1'
    base: /de/
    typo3Language: de
    locale: de_DE.utf8
    iso-639-1: de
    navigationTitle: Deutsch
    hreflang: de
    fallbackType: strict
    flag: de
  -
    title: Polski
    enabled: false
    languageId: '2'
    base: /pl/
    typo3Language: pl
    locale: pl_PL.utf8
    iso-639-1: pl
    navigationTitle: Polski
    hreflang: pl
    fallbackType: strict
    flag: pl
  -
    title: Türkçe
    enabled: true
    languageId: '3'
    base: /tr/
    typo3Language: tr
    locale: tr
    iso-639-1: tr
    navigationTitle: Türkçe
    hreflang: tr
    fallbackType: strict
    flag: tr

The hreflang tags are generated with the scheme:

<link rel="alternate" hreflang="en" href="https://www.example.com/en/"/>
<link rel="alternate" hreflang="de" href="https://www.example.com/de/"/>
<link rel="alternate" hreflang="tr" href="https://www.example.com/tr/"/>
<link rel="alternate" hreflang="x-default" href="https://www.example.com/en/"/>

Perhaps your HTML code is changed by another extension or tool?

Actions #3

Updated by Richard Haeser over 5 years ago

  • Status changed from New to Closed

Hi,

I can't reproduce either. It seems not to be a bug but maybe a configuration. I would suggest to check the #cig-seo channel on Slack to discuss and maybe people can help you finding the issue. If it after all seems to be a bug, we can reopen this issue. For now, I will close it.

Richard

Actions #4

Updated by Jonas Eberle over 5 years ago

It is induced by the

base: '/'

in the site config.

I can reproduce this in T3v9 and get canonical URLs like

<link rel="canonical" href="/"/>

in that case.

Can not investigate deeper right now.
I have this TypoScript:
  • config.baseURL=https://mydomain.com
  • config.absRefPrefix=/

Basically the workaround is to NOT use / in the site config.

Actions #5

Updated by Jonas Eberle over 5 years ago

Sorry, I actually forgot to post the hreflang output in that case:

<link rel="alternate" hreflang="de-DE" href="/"/>
<link rel="alternate" hreflang="de-AT" href="/at/"/>
Actions #6

Updated by Jonas Eberle over 5 years ago

It is independent of the config.baseURL and config.absRefPrefix.

Actions #7

Updated by Jonas Eberle over 5 years ago

I can reproduce in master after a clean install (FIRST_INSTALL, then select "create home page", add a site language [tg in my case], translate home page)

rootPageId: 1
base: /
languages:
  -
    title: English
    enabled: true
    languageId: '0'
    base: /
    typo3Language: default
    locale: en_US.UTF-8
    iso-639-1: en
    navigationTitle: English
    hreflang: en-us
    direction: ltr
    flag: us
  -
    title: Togo
    enabled: true
    languageId: '1'
    base: /fr/
    typo3Language: fr
    locale: fr_TG.UTF-8
    iso-639-1: fr
    navigationTitle: ''
    hreflang: fr-tg
    direction: ''
    fallbackType: strict
    fallbacks: '0'
    flag: tg
errorHandling: {  }
routes: {  }
baseVariants: {  }

This outputs:


<link rel="alternate" hreflang="en-us" href="/"/>
<link rel="alternate" hreflang="fr-tg" href="/fr/"/>
<link rel="alternate" hreflang="x-default" href="/"/>

<link rel="canonical" href="/"/>

Actions #8

Updated by Georg Ringer over 5 years ago

If no domain is set, it won't be prepend to the urls. This is also documented in the site module.

Reason is that the domain can't be calculated, eg in cli context, or backend context.

Please don't use / but provide a proper domain.

Actions #9

Updated by Jonas Eberle over 5 years ago

IMHO it would be better to throw an error then before creating incorrect hreflangs.

Even more helpful would be if it would not throw an error in a web request though, because the HOST would be available there.

Maybe something like

base: "req('HOST')/"

in the site config would be possible to overcome this and actually remove the need to configure baseVariants?

Actions

Also available in: Atom PDF