Project

General

Profile

Actions

Feature #93606

closed

Disable canonical URLs on a per page basis

Added by Aimeos no-lastname-given about 3 years ago. Updated almost 3 years 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.

Actions #1

Updated by Georg Ringer about 3 years ago

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

Updated by Georg Ringer about 3 years ago

  • Status changed from New to Rejected
Actions #3

Updated by Georg Ringer about 3 years ago

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

Updated by Georg Ringer about 3 years ago

  • Status changed from Rejected to New
Actions #5

Updated by Aimeos no-lastname-given about 3 years 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://..." />

Actions #6

Updated by Richard Haeser about 3 years 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.

Actions #7

Updated by Richard Haeser about 3 years ago

  • Assignee set to Richard Haeser
Actions #8

Updated by Richard Haeser about 3 years ago

  • Status changed from New to Accepted
Actions #9

Updated by Gerrit Code Review about 3 years 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

Actions #10

Updated by Aimeos no-lastname-given about 3 years 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.

Actions #11

Updated by Richard Haeser about 3 years 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.

Actions #12

Updated by Aimeos no-lastname-given about 3 years 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.

Actions #13

Updated by Richard Haeser about 3 years 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.

Actions #14

Updated by Aimeos no-lastname-given about 3 years 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.

Actions #15

Updated by Gerrit Code Review about 3 years 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

Actions #16

Updated by Gerrit Code Review about 3 years 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

Actions #17

Updated by Richard Haeser about 3 years ago

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

Updated by Benni Mack almost 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF