after changing the name of an article-alias the canonical url is wrong
There is a category-blog on my site having article-urls like:
/blog/123-article-title
Now i change the alias and the url becomes:
/blog/123-better-alias
I would expect then whenever visiting the old url the canonical in the header would be set to the new url
so when visiting /blog/123-article-title the canonical is set to /blog/123-better-alias
however the canonical is set to something like :
/blog?catid=123&id=123:better-alias
and that url returns a 404.
The problem is somewhere in the router of the component in line 377 it checks whether or not the alias in the database is the same as from the slug, which isn't . So the code goes into the !advanced ( I can't find where the sef_advanced_link parameter is actually set and what is does) statement where it fetches the catid from the first segment, which is actually the article-id
Tested on 3.5.1 RC 1 and now it simply returns the 'current' url
so
/blog/123-article-title -> canonical /blog/123-article-title
/blog/123-better-alias -> canonical /blog/123-better-alias
but these are the same pages so it should be
/blog/123-article-title -> canonical /blog/123-better-alias
The sef plugin checks for a canonical relation link set, where is that option hidden? It is not set by com_content automagicly
so it got worse - a lot - the sef plugin does not recalculate the current url for the current menu and category structure, neither does com_content.
I think this will give you wrong canonicals whenever: moving an article to a different category, renaming a category, creating a new menu for a category, changing the alias.
The SEF plugin, if the Domain is set, will indeed just display the canonical with the new domain and the same structure. It is not a "real" canonical which can only be implemented by third party extensions.
See #9565
@andrepereiradasilva
Please look at this, as it is confusing to me.
So you condider the com_content as a third party extension?
Right, then move this topic into their bin.
In 3.5.0 the sef plugin used the router of com_content, getting the correct url ( reflecting changed to the sites structure) for most situations. The implementation in 3.5.1 RC1 is a serious step back
SEF plugin could never insert correct canonical URLs, which is why this functionality has been removed in 3.5.1. Now the "canonical" URL is inserted only when canonical domain is set. It's better to have no canonical than a wrong one that even changes based on accessed URL.
What infograf meant, you can use a third party plugin to insert canonical URLs. You can also do this in template override. If the team agreed, canonicals could be inserted by components. But that's up to them to decide. Maybe the idea was to have a single plugin insert canonicals, IDK.
The problem was that in 3.5.0, i think by mistake, Joomla was generating canonical URI trough the SEF plugin when no alternative domain is typed.
The following PR (#9565) corrects, among other things, that.
There is a problem with Joomla regarding generation of canonical URI, it has to be made at component level.
That problem will make you could have an infinite number of canonical URIs for the same page.
More information is in that PR comments.
i see @SharkyKZ already explained that better :)
As far as I know, when the domain was indicated in the SEF plugin field, the canonical was always the same URL (except the domain) as the present url. Changing an alias would change both the base href and the canonical.
The problem was that in 3.5.0, i think by mistake, Joomla was generating canonical URI trough the SEF plugin when no alternative domain is typed.
That was also the case in 3.4.8, and in fact for a long time.
As I wrote above, real canonicals i.e. indicating a unique canonical for all URL instances loading the same page is NOT implemented in Joomla core.
The URL inserted was $domain . JRoute::_('index.php?' . http_build_query($router->getVars()), false);
which isn't necessarily the same as current URL (JUri::getInstance()
), but also incorrect.
That was also the case in 3.4.8, and in fact for a long time.
Just checked the SEF plugin history, Joomla is in fact inserting fake canonical for some time now.
[...]You can also do this in template override. [...]
Actually i think in 3.5.1 RC you just need to add, in the SEF plugin canonical domain field, the same domain URI as your site (e.g. https://www.example.com) and Joomla will put the fake canonical URI, that, in fact, will be the current URI. But i see no point in doing this.
No, joomla 3.5.1 RC will simply take the current wrong url and replace the domain name.
so http://example.com/blog/123-wrong-alias gets http://www.example.com/bolg/123-wrong-alias.
I needed about 4 lines of code into the default.php of the article view to get the correct canonical into the head.
A correct canonical to reflect site structure changes should be in the core of any joomla component, should have been there from the first day the canonical tag popped up.
No, joomla 3.5.1 RC will simply take the current wrong url and replace the domain name.
I know. That's what i said.
I guess this can be closed.
@brianteeman i think you can close this
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-04 10:57:56 |
Closed_By | ⇒ | infograf768 |
Set to "closed" on behalf of @infograf768 by The JTracker Application at issues.joomla.org/joomla-cms/9643
Which version of Joomla? Please test on 3.5.1 rc1. Canonical (from the SEF plugin code) has been improved to cope with extensions implementing it.