New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solve SEF canonical issues #9565
Conversation
@scence @SharkyKZ @infograf768 @ggppdk @chivitli Can you test this and check if all issues are resolved? |
@wilsonge if tested ok, IMHO should go to 3.5.1 |
{ | ||
$doc = $this->app->getDocument(); | ||
$doc = JFactory::getDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason this can't be $this->app->getDocument()
still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You get a fatal error if you try to access it like that in onAfterRoute event
Sorry, clarification, you get a fatal error after, because it returns null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes ... try it and you'll see ... php errors.
it seems if you use the $this->app->getDocument();
in onAfterRoute event you get problems. Don't know why. Maybe @mbabker knows better why this happens.
BTW that has the whole reason i change it to onAfterDispatch
earlier. After component rendering you can use it.
If canonical is added only when domain is set, there is no need to revert other changes since in this case SEF plugin should override components anyway. Otherwise components would not use the canonical domain. In such a case, canonical should simply be the specified domain + current path. |
By my logic, it would be best to check for existing canonicals before doing anything.
|
ok so let me try to code something for that. |
ok i changed the code. How it works now:
Please check code and test. Open to any suggestions/improvements regarding this. |
Nice and simple to allow components to add rel canonical without reverse engineering anything
|
It doesn't override component canonicals when canonical domain is set. |
For me this is good, I would never override canonical from a custom component. The rest works as described. So, test ok from me. It still remains an issue though that canonicals generated this way are not real canonicals, so I am not sure if this is useful at all (or that it doesn't have a negative impact). |
I just realized you would like the plugin to replace the domain part of the custom component - that sounds like a good idea. At present, this is indeed not the case. |
I will add this them. |
please check now. |
Test successful, works as described. |
Test instructions updated. @chivitli if it's ok for you. please mark as "Tested successfully" in "Joomla! Issue Tracker" https://issues.joomla.org/tracker/joomla-cms/9565 (after login the "Test this" button appears). |
I have tested this item ✅ successfully on d00b99c This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
I have tested this item ✅ successfully on d00b99c This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
Sorry folks, but I am totally lost...
As far as I know, a canonical link is only used to show Search Engine the preferred url when multiple URLs reach the same page Why then create a canonical when only one URL exists? |
I do now understand though that we get also a canonical before this patch when loading another page than the home as I have indeed overseen that in my former tests... |
There are always multiple urls in Joomla. Not only multiple, but an infinite number of them... As mentioned, Google says: Mark up the canonical page and any other variants with a rel="canonical" link element. There is no need for this optimization to not show canonical on the canonical page. |
Are'nt we going to get a canonical for ANY page loaded this way. I mean when we have another url to get to the same page, we would have a different canonical. |
Ok the plugin, previously had code:
Now it WILL happen that it will add 2 (different) rel canonical for 2 pages that are same But
|
I don't know google having special code to try to detect if 2 pages are the same if rel canonical is missing, furthermore which 2 pages would it compare and why it try to compare them ?
|
This PR has received new commits. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
ok. updated the code, now it ONLY adds (or changes in the case a component already added) the canonical if the SEF plugin domain field has some value. Test instructions updated in the first post, please test now. |
This PR has received new commits. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
Since canonical URL is now used only to canonize domains, it can be left as current path with canonical domain prepended. Routed URL is incorrect anyways, so no point in leaving it there. |
right, you're right will change it |
This PR has received new commits. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
done please retest and mark the test result again. |
I have tested this item ✅ successfully on 86f63a6 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
1 similar comment
I have tested this item ✅ successfully on 86f63a6 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
@infograf768 ok for you now too? |
@@ -22,6 +22,7 @@ | |||
<field name="domain" type="url" | |||
description="PLG_SEF_DOMAIN_DESCRIPTION" | |||
label="PLG_SEF_DOMAIN_LABEL" | |||
hint="https://www.domain.tld" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an example link can you make sure it uses example.com please :) thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
This PR has received new commits. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
Just a little change at @wilsonge request, no need to retest. |
I have tested this item ✅ successfully on 99b82a7 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
It is now behaving as should. Thanks! RTC You can merge into 3.5.1 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9565. |
Merged - thanks :) |
@SharkyKZ @chivitli @infograf768 @ggppdk @wilsonge thanks for tests and/or contributions. |
This Pull Request is related to issues #9333 and #9556.
Also to PR #9559
Summary of Changes
Add a better check for adding the canonical html tag.
Testing Instructions