J4 Issue ?
avatar kartzke
kartzke
6 Jul 2019

Steps to reproduce the issue

Applies to multi-lingual Joomla websites with mod_rewrite and SEF URLs turned on.

In the Joomla plugin "System - Language Filter", there is an option to "Remove URL Language Code". See attached screenshot.

This feature removes the language code from the URL for the websites default language. So for example, with English set as the default site language, this option would remove /en/ from the URL.

This feature works as expected. But the Language Switcher Module is not aware of this option when a user is viewing a non-EN page.

For example, if I am on a page in Thai, the URL might be something like:

If I use the language switcher to change to English, the alternate URL will be constructed with the /en/ language code:

Which then 301 redirects to:

Expected result

When the "Remove URL Language Code" feature is enabled, the language switcher module should not include the language code for the default site language. Using the example above, it should link to this URL

Actual result

The language switcher module does include the language code, triggering an unnecessary 301 redirect. This causes an extra server request, delays the user experience and wastes SEO crawl budget.

System information (as much as possible)

Setting | Value
Database Type | mysql
Database Version | 5.7.25-log
Database Collation | latin1_swedish_ci
Database Connection Collation | utf8mb4_general_ci
PHP Version | 7.3.6
Web Server | Apache
WebServer to PHP Interface | cgi-fcgi
Joomla! Version | Joomla! 3.9.8 Stable [ Amani ] 11-June-2019 20:00 GMT
Joomla! Platform Version | Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT

Additional comments

On large websites, this can be an impactful optimisation that helps improve the user experience, optimise server resources and improve SEO by conserving crawl budget and potentially consolidating pagerank.

Screen Shot 2019-07-06 at 19 28 39

avatar rhotog rhotog - open - 6 Jul 2019
avatar joomla-cms-bot joomla-cms-bot - change - 6 Jul 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 Jul 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Jul 2019
Title
Improve SEO -> Minimize Redirects on Multi-Language Websites
[4.0] Improve SEO -> Minimize Redirects on Multi-Language Websites
avatar franz-wohlkoenig franz-wohlkoenig - edited - 6 Jul 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Jul 2019
Labels Added: J4 Issue
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 6 Jul 2019
avatar ghost
ghost - comment - 7 Jul 2019

Please can a Bug Squad Team-Member answer as this Issue is opened more than 12 hours ago?

avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Jul 2019
Status New Information Required
avatar infograf768
infograf768 - comment - 7 Jul 2019

afaik we do absolutely need to include the 'sef' prefix when using Remove Language Code, even if the final result is to not display it for Search Engines for the site default language.
The redirects are done on purpose and the switcher is not at stake.
See:
https://github.com/joomla/joomla-cms/blob/staging/plugins/system/languagefilter/languagefilter.php#L461-L478

avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Jul 2019
Status Information Required Discussion
avatar kartzke
kartzke - comment - 7 Jul 2019

@infograf768 Thanks for the feedback! But why is this absolutely needed? Couldn't the front-end logic be set up to exclude the default language code when that option is enabled? Joomla seems to operate this way when viewing the site in the default language.

Meaning, if I am viewing a site in English (the default) and I navigate to the language switcher, the URL does not include /en/. But if I'm on a non-EN page, then the /en/ prefix is included. So this scenario creates an extra redirect, which is much better than not having it, but still not ideal.

avatar infograf768
infograf768 - comment - 7 Jul 2019

Basically, a new user has no cookie set or the cookie has expired.
Let's say the default site language is set to en-GB (sef prefix is "en". But the user browser preferred language is set to it-IT (sef is "it")

When this user tries to load mysite.com/ from somewhere on the web, Joomla checks the browser default language and IF it finds it, redirects to mysite.com/it/ and NOT to the en-GB version.

same for en-GB if preferred browser language is en-GB, it will redirect to mysite.com/en/
Joomla understands that and will modify the url to not display the sef prefix.

Note: It is important to set your site map with the prefix for each language.

avatar Slava287
Slava287 - comment - 28 Mar 2022

As a result, as I understand it, for large sites it is better to leave the display of the prefix for the default language in order to save the crawling budget?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25449.

Add a Comment

Login with GitHub to post a comment