#103642Alternate hreflang x-default
Description
The meta tag “x-default” can currently only be changed by manually adjusting the order in the language array of the sites.yaml file. It is not possible to change the order in the backend.
The good news is that by changing the order, the correct x-default value is actually used in the frontend. In my case languageId: 2
languages:
- languageId: 2
enabled: true
title: Englisch
websiteTitle: fellow.dog
base: 'https://www.fellow.dog/'
locale: en_US.utf8
navigationTitle: English
direction: ''
fallbackType: strict
fallbacks: ''
flag: en-us-gb
deeplTargetLanguage: EN-US
- languageId: 0
enabled: true
title: Deutsch
base: 'https://www.darf-ich-mit.de/'
locale: de_DE.utf8
navigationTitle: Deutsch
direction: ''
flag: de
websiteTitle: ''
deeplTargetLanguage: DE
But now to the problem. Due to the change, my languageId 0 (German) is hidden in the backend when I want to edit pages. (see screenshot)
I have come across the problem with the x-default several times now, both privately and professionally, and would very much like to be able to adjust the x-default value in the sites config
The use of the EXT:cs_seo extension offers this feature, but only halfway, because the URLs for RouteEnhancers are not resolved. Therefore their feature is unfortunately unusable
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Files 1
History 6
-
Mark Weisgerber commented 04/16/24, 18:26
-
Mark Weisgerber changed attached 2024-04-16 19_04_50-Window.png 04/16/24, 18:28
-
Stefan Bürk commented and changed status
NewNeeds Feedback 04/20/24, 20:09TBH I have not tested it by myself, but the siteconfiguration allows to manual set
hreflang labels for a language. And the documentation states, that it can be used
to manually define the `x-default` language.Granted, there is a note for 12.4 that this is retrieved from the locale, but as the href field is still there it may work to set it for the
whished language as `default` (or x-default`).I could not see if you have tried that already.
Sorting the languages manually is not good, and languageId = 0 should always be the first one. It’s technical the default language throughout TYPO3 and moving it away does not match the generic design and expectation – which confirms your issue after resorting it manually. I guess, all foreign language can be resorted, but leave languageId = 0 as first language per SiteConfiguration.
-
Georg Ringer commented and changed status
Needs FeedbackClosed 08/04/24, 08:40hey!
as you mentioned changing the options is not really a good way as it leads to unexpected results.
I propose that you use the event to modify the x-default option. We won’t provide yet another checkbox in the core as the default is good enough and anything else depends on so many things? have also seen seo agencies which wanted the x-default to vanish and maybe a usecase could be that an editor is allowed to choose the correct language, …
therefore please use the event and implement it in your site package or maybe as small extension and publish it.
if you don’t agree, feel free to contact me via slack! -
Fronzes Philippe commented 05/21/25, 08:57
I think x-default is not implemented correctly.
This value should be used to redirect visitors to a page where they can choose their preferred language, not to specify the default language of the site.
(See: https://developers.google.com/search/docs/specialty/international/localized-versions#xdefault)
If such a page does not exist, hreflang=“x-default” should not be present on the site. -
Guillaume Crico commented 11/27/25, 14:29
I think that Philippe Fronzes comment is relevant.
> This value should be used to redirect visitors to a page where they can choose their preferred language, not to specify the default language of the site.
But maybe this requires a separate ticket ?
If you need a workaround (hardcoded and not based on the LanguageID) until there is something official:
Services.yaml:
EventListener: