Bug #88703
closedGenerated alternate hreflang urls have not allowed transport method
0%
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"
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: { }
Updated by Georg Ringer over 5 years ago
- Category changed from System/Bootstrap/Configuration to SEO
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?
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
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.
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/"/>
Updated by Jonas Eberle over 5 years ago
It is independent of the config.baseURL and config.absRefPrefix.
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="/"/>
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.
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?