RTC RMDQ PR-6.0-dev Pending

User tests: Successful: Unsuccessful:

avatar MacJoom
MacJoom
4 May 2025

Pull Request for Issue #42128

Summary of Changes

Adds separate array in the document for hreflang tags, thus enabling them to be separate of other link tags e.g. having a canonical tag with the same link, does selfreferencing to the same page as recommended by Google, while keeping the canonical tag.

Testing Instructions

Install Joomla with multiple languages.

In the 'System - Language Filter plugin', make sure 'Add Alternate Meta Tags' is set to True (default)

In the 'System - SEF' plugin enter a 'Site Domain' (default empty)

Inspect the source of the Website

Actual result BEFORE applying this Pull Request

There is only one link of the actual url either 'canonical' or 'alternate' hreflang="en-GB"

       <link href="http://release6-0.test/joomla-cms/index.php/de" rel="alternate" hreflang="de-DE">
       <link href="http://release6-0.test/joomla-cms/index.php/en" rel="canonical">

Expected result AFTER applying this Pull Request

        <link href="http://release6-0.test/joomla-cms/index.php/en" rel="canonical">
..
        <link href="http://release6-0.test/joomla-cms/index.php/de" rel="alternate" hreflang="de-DE">
	<link href="http://release6-0.test/joomla-cms/index.php/en" rel="alternate" hreflang="en-GB">

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar MacJoom MacJoom - open - 4 May 2025
avatar MacJoom MacJoom - change - 4 May 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 May 2025
Category Libraries
avatar MacJoom MacJoom - change - 4 May 2025
The description was changed
avatar MacJoom MacJoom - edited - 4 May 2025
avatar MacJoom MacJoom - change - 4 May 2025
The description was changed
avatar MacJoom MacJoom - edited - 4 May 2025
7179cf0 4 May 2025 avatar MacJoom cs
avatar MacJoom MacJoom - change - 4 May 2025
Labels Added: PR-6.0-dev
avatar MacJoom MacJoom - change - 4 May 2025
The description was changed
avatar MacJoom MacJoom - edited - 4 May 2025
avatar fgsw fgsw - test_item - 6 May 2025 - Tested successfully
avatar fgsw
fgsw - comment - 6 May 2025

I have tested this item ✅ successfully on 0e829dc

BEFORE applying this Pull Request

IMG_0157

AFTER applying this Pull Request

Untitled
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45428.
avatar exlemor exlemor - test_item - 10 May 2025 - Tested successfully
avatar exlemor
exlemor - comment - 10 May 2025

I have tested this item ✅ successfully on 0e829dc

I have successfully tested this PR.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45428.
avatar QuyTon QuyTon - change - 10 May 2025
Status Pending Ready to Commit
avatar QuyTon
QuyTon - comment - 10 May 2025

RTC


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

avatar QuyTon QuyTon - change - 10 May 2025
Labels Added: RTC
avatar QuyTon
QuyTon - comment - 12 May 2025

@MacJoom Please check to see if PR #45383 is solving the same issue as this. Thanks!

avatar MacJoom
MacJoom - comment - 12 May 2025

#45383 is just a workaround - this PR does what the author was hoping for in the comment // This is hopefully temporary until HTML document head links can manage multiple // entries for the same URL.
With this PR it is possible to have hfrelang link tag and canonical link tag with the same link

avatar weeblr
weeblr - comment - 13 May 2025

Hi,

Sorry, was away, could not comment earlier here.

@MacJoom To me, this PR is the same sort of workaround than mine (#45883). It does not solve the problem globally and certainly does not achieve "// This is hopefully temporary until HTML document head links can manage multiple // entries for the same URL.".

Typically, you would not still be able to target the same URL with a prerender or preload rel attribute.

It all comes down to this:

    public function addHeadLink($href, $relation, $relType = 'rel', $attribs = [])
    {
        $this->_links[$href]['relation'] = $relation;
        $this->_links[$href]['relType']  = $relType;
        $this->_links[$href]['attribs']  = $attribs;

        return $this;
    }

which assumes incorrectly that the same href can be used only in one <link> element.

That's what I meant by "HTML document head links can manage multiple entries for the same URL".
And also that I don't see how this can be achieved without a big B/C break, which is why I made that simple PR.

With that concern noted, your PR is as good as mine, and I consider very important that a fix is brought to Joomla as quickly as possible, as this is a very serious SEO issue.

avatar MacJoom
MacJoom - comment - 13 May 2025

Hi @weeblr and thank you for your contribution. What about adding 'prerender' and 'preload' tag the same as 'hreflang'? This PR just adds the possibility to add 'hreflang' tags without interfering with other links. @hikashop-nicolas what do you think?

avatar weeblr
weeblr - comment - 13 May 2025

Not sure this is needed honestly, altough I can see use cases, for instance, wanting to preload the alternate languages for quick switching but that's a bit far fetched.

Your PR or mine solve the pressing issue of invalid hreflang, which is all that matters.

avatar MacJoom
MacJoom - comment - 13 May 2025

This PR fixes the issue that hikashop-nicolas has. He would like to have a canonical tag as well all hreflang tags at the same time.

avatar weeblr
weeblr - comment - 13 May 2025

This PR fixes the issue that hikashop-nicolas has. He would like to have a canonical tag as well all hreflang tags at the same time.

That's not the actual issue and is not something "Nicolas wants".

It's an enormous SEO issue for Joomla, which is that if a user enters anything in the "Site domain" input field in the SEF system plugin, Joomla will output a canonical tag. Usually a wrong one, but that's something we can live with.

However, when Joomla outputs a canonical, it cannot also output an hreflang - until your PR or mine is merged.

Which means all Joomla multilingual websites have had that critical SEO issue for a very long time.

I'm not sure how it went unnoticed that long. In my case, I became aware of it because some users of my extensions reported it, thinking 4SEO may be a way to solve that problem.

I think the issue has become more important in recent times due to the addition of new options in the SEF system plugin (handling of index.php, trailing slash,...). Users who never opened the SEF system plugin options did so to check these new settings and saw the "Domain site" field, thinking it was a cheap way to add a canonical tag to their page. And so they filled it up, triggering the issue on all multilingual sites.

So in short, it's a major, major issue and it should be fixed ASAP.

avatar universewrld
universewrld - comment - 13 May 2025

Users who never opened the SEF system plugin options did so to check these new settings and saw the "Domain site" field, thinking it was a cheap way to add a canonical tag to their page. And so they filled it up, triggering the issue on all multilingual sites.

So in short, it's a major, major issue and it should be fixed ASAP.

I'm one of such users and I described #42720 this problem more than a year ago when I enabled the "canonical" links option in the default System - SEF plugin.

avatar hikashop-nicolas
hikashop-nicolas - comment - 13 May 2025

I agree with @weeblr that this is a major SEO problem for multilingual websites on Joomla. I didn't report the issue because this is something HikaShop needs. I reported it because it is a problem for any page of a Joomla website with a canonical tag (which they should have for better SEO) and multilingual tags (which they should have on multilingual websites for better SEO).
The patch in the PR #45383 is a similar short term solution than what I proposed in the issue #42128
That's something that could be added in J5.
The PR here is a cleaner long term solution for J6 as it can break backward compatibility.
But as @weeblr said, even this PR doesn't address the real issue which is that the Document class uses the URL of the meta tag as a key and thus, you can't have the same URL on different link tags with different "rel". Your PR here circumvents the issue by using another array for hreflang link tags. The array should, I think, use both the URL and the rel attribute as key, not just the URL. That would prevent this issue from being reported again in the future with other types (with a different "rel") of link meta tags.
But that will break B/C even more. So I'm not sure if it is worth doing it.

avatar weeblr
weeblr - comment - 13 May 2025

Users who never opened the SEF system plugin options did so to check these new settings and saw the "Domain site" field, thinking it was a cheap way to add a canonical tag to their page. And so they filled it up, triggering the issue on all multilingual sites.
So in short, it's a major, major issue and it should be fixed ASAP.

I'm one of such users and I described #42720 this problem more than a year ago when I enabled the "canonical" links option in the default System - SEF plugin.

Hi @universewrld You should likely remove whatever you entered in that field to disable the Joomla canonical tag output. It is only useful in on single case: if your site can be accessed through several domains (ie mysite.com, mysite.net, ...). And even in that case, the generated canonical will be wrong in most cases it's needed.

Thanks for the link to your issue, I see it was closed as a duplicate of #26416 (in which I participated!) but there was no solution at the time.

avatar MacJoom
MacJoom - comment - 13 May 2025

I know the problem but i did not know that there are that many different link tag options that matter. I could make a PR that uses both url and rel as key - may be you can tell me more about possible B/C breaks that can happen and i can discuss it with the maintainers

avatar weeblr
weeblr - comment - 13 May 2025

I could make a PR that uses both url and rel as key

I don't think that'd be the long term approach. There should just not be any URL key. The "links" property should just be an array where you push new links. Then each record is an array with all required values for that link element.

$this->_links[] = $newLinkDefinition1; // most type of links can have multiple instances for the same URL
$this->_links[] = $newLinkDefinition2; // there should only be one canonical though, must check that

You can certainly index on the relation, if that helps later:

$this->_links['alternate'][] = $newLinkDefinition1; // most type of links can have multiple instances for the same URL
$this->_links['alternate'][] = $newLinkDefinition2;

$links['canonical'][] = $newLinkDefinition3; // there should only be one canonical though, must check that

BUT

I would not do that as I'm pretty sure there are extensions checking the value or existence of a given head link, as $this->_links is/was a public property, these extensions expects the $this->_links[$href] format.

Changing that would create a huge mess. Considering the main issue is the invalid hreflang, I'd suggest sticking to your solution and not create an even bigger issue.

avatar universewrld
universewrld - comment - 13 May 2025

Hi @universewrld You should likely remove whatever you entered in that field to disable the Joomla canonical tag output. It is only useful in on single case: if your site can be accessed through several domains (ie mysite.com, mysite.net, ...). And even in that case, the generated canonical will be wrong in most cases it's needed.

Thanks for the link to your issue, I see it was closed as a duplicate of #26416 (in which I participated!) but there was no solution at the time.

I simply don't use this option anymore after the Site Domain setting started adding a rel="canonical" tag to non-canonical URLs.

Since migrating to Joomla 4, SEO in Joomla has been terrible, I don't remember having such big SEO issues when using Joomla 1.5, 2.5 and 3.x

I think the Site Domain URL setting should always point to canonical URLs only, regardless of whether other domains are used for the website or not, because it is not correct to add a rel="canonical" tag to every link of the specified domain.

avatar weeblr
weeblr - comment - 13 May 2025

I think the Site Domain URL setting should always point to canonical URLs only, regardless of whether other domains are used for the website or not, because it is not correct to add a rel="canonical" tag to every link of the specified domain.

You are right (except for the fact that Joomla has no real way of knowing what the canonical page is).

I'd suggest however we do not enter this discussion here, as it's a separate issue from the one at hand, and we risk derailing a quick resolution of the current (even bigger) problem: invalid hreflang.

avatar QuyTon QuyTon - change - 14 May 2025
Labels Added: RMDQ
avatar MacJoom
MacJoom - comment - 18 May 2025

I will do a rework and use a Registry for the links. _links will be deprecated but will be kept for B/C.

avatar weeblr
weeblr - comment - 19 May 2025

@MacJoom That'd be great but please do this in another PR/project. This is a (very big) bug and it needs to be solved ASAP.

So I'd suggest merging either you current PR, or mine, but the problem must be solved now, even if a more general solution can be used in the future.

I don't know why this was tagged as [6.0]. It is a bug in 5.x and again it needs to be solved, it certainly cannot wait until 6.0, nor does it need to.

avatar bettingexchange
bettingexchange - comment - 3 Jun 2025

as i have already comunicate in github and many people write, there is now a very BIG ISSUE for all multilanguages site in Joomla.
If you leave the slash to home page with plugin filter language, and in SEF system plugin you select force without final slash and you don't have the language code in home page (for example it default and /es and /en the other 2 languages) there is this issue:

in the /es and /es home pages (ONLY) there is x-default and it-it hreflang with the language code /it but I don't want the code IT in home page and there is not the Langauge Code all options (language filter plugin etc)
other issue only in all pages in italian language that don't have the associations with other languages ( es and en) there is not x-default hreflang.
So the problem is in home page of other languages (not default) and in all language default pages with not other languages associations.
I think that the problem is System SEF plugin. Without this plugin there is not issue but there is the slash in the pages of site example /es/ and /en/ that it is a seo problem.

avatar QuyTon QuyTon - change - 3 Jun 2025
Status Ready to Commit Pending

Add a Comment

Login with GitHub to post a comment