Feature #93606

Disable canonical URLs on a per page basis

Added by Aimeos no-lastname-given 7 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Category:
SEO
Target version:
-
Start date:
2021-02-28
Due date:
% Done:

100%

Estimated time:
PHP Version:
7.4
Tags:
seo, duplicate, canonical
Complexity:
Sprint Focus:

Description

In TYPO3 9/10 it's only possible to disable canonical URL completely by unsetting the canonical URL provider.

Problem:
In Aimeos, we generate the HTML header ourselves including the canonical URL e.g. for the shop products. As it's not possible to disable generating the canonical URL on a per page basis, the HTML page served by TYPO3 will either contain only canonical URLs for the shop pages added by Aimeos or two canonical URLs in the HTML of the shop pages which is bad for SEO.

#1

Updated by Georg Ringer 7 months ago

  • Related to Feature #93188: Possibility to disable hreflang per page added
#2

Updated by Georg Ringer 7 months ago

  • Status changed from New to Rejected
#3

Updated by Georg Ringer 7 months ago

  • Related to deleted (Feature #93188: Possibility to disable hreflang per page)
#4

Updated by Georg Ringer 7 months ago

  • Status changed from Rejected to New
#5

Updated by Aimeos no-lastname-given 7 months ago

@Georg: Sorry, I don't see how config.disableHrefLang also disables canonical URLs because the patch disables alternate language URLs:

<link rel="alternate" hreflang="de" href="https://..." />

While I'm talking about SEO canonical URLs pointing to one page that's available with different URLs (not necessarily different languages):
<link rel="canonical" href="https://..." />

#6

Updated by Richard Haeser 6 months ago

Will add this to my todo.

But what is the reason that you don't use the official API's? You can use a PSR-14 event to define the canonical yourself. You can use the event ModifyUrlForCanonicalTagEvent for that. I would not recommend doing it "yourself" as this will lead into the issue we always had: there is no way extensions can work together and define which extension should render the tag and might lead into duplicate tags (as you have now). I'm really looking for use cases which can't be done by the official API.

#7

Updated by Richard Haeser 6 months ago

  • Assignee set to Richard Haeser
#8

Updated by Richard Haeser 6 months ago

  • Status changed from New to Accepted
#9

Updated by Gerrit Code Review 6 months ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68258

#10

Updated by Aimeos no-lastname-given 6 months ago

Thanks for the patch!
We create a bunch of header tags in Aimeos if their content directly depends on the shop product data. Using the TYPO3 API would require us to fetch the data again from the database in the TYPO3 MVC controller which we want to avoid. Thus, in our case it's for performance reasons.

#11

Updated by Richard Haeser 6 months ago

So basically you want to be able to set the canonical (and href I guess) by a controller? I will think about if this is something that is already possible or otherwise if we can make this easily possible.

#12

Updated by Aimeos no-lastname-given 6 months ago

No, in our case we want to avoid setting the canonical URL in the controller for performance reasons. If we can disable it in the controller, we are totally fine.

#13

Updated by Richard Haeser 6 months ago

Well, my goal is that you should never ever set those tags manually yourself, but doing it by the official API. If I understand you correctly, using an EventListener will cause an extra db call in your situation while you have that information in the controller action isnt it? So if you can set the canonical link in your controller, that would be good isn't it? I assume you always want to have a canonical especially with products and categories in ecommerce.

#14

Updated by Aimeos no-lastname-given 6 months ago

Aimeos is a bit special because it supports multiple frameworks and applications. For that, the "controller" logic for retrieving the data and passing it to the views is encapsulated in a view model object (called "HTML Cllient"). In the TYPO3 MVC controller we don't have access to the product data any more because all TYPO3 MVC controller actions are dumb and only returning the response from the view model. Here's the TYPO3 MVC catalog controller where you can see the implementation:
https://github.com/aimeos/aimeos-typo3/blob/master/Classes/Controller/CatalogController.php#L48-L53

We pass a PSR-7 request to the view model and would return a PSR-7 response to TYPO3 but Extbase doesn't support that so it's still a string and the generated headers are added to the TYPO3 page here:
https://github.com/aimeos/aimeos-typo3/blob/master/Classes/Controller/AbstractController.php#L159-L167

As you can see, we don't have data from the view model in the TYPO3 MVC controller so offering a method to set the canonical tag there makes no sense for us. The ability to disable generating canonical tags is all we need.

#15

Updated by Gerrit Code Review 6 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68258

#16

Updated by Gerrit Code Review 6 months ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68258

#17

Updated by Richard Haeser 6 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#18

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF