Bug #87760

Epic #89797: HrefLang / Canonical issues

Option to remove params from canonical tag

Added by Patrick Fiedorowicz 10 months ago. Updated 13 days ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
SEO
Target version:
-
Start date:
2019-02-21
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I have a page with news plugin and pagination.
Each pagination url and also the canonical tag looks like:
- example.com/news/2/
- example.com/news/3/
- example.com/news/.../

Currently there is no possibility to remove the tx_news_pi1[@widget_0][currentPage] param from the canonical tag.

I've tested the behaviour with and without RouteEnhancers, no changes.

The CanonicalGenerator uses a function "getParamsToExcludeForCanonicalizedUrl" in "TYPO3\CMS\Frontend\Utility\CanonicalizationUtility" to determine which params should be removed from the canonical tag.
But at the moment this only removes params wich should be ignored for chash calculation - but this is no solution for pagination widget.


Related issues

Related to TYPO3 Core - Feature #88242: Make canonical optional Resolved 2019-04-28

History

#1 Updated by Richard Haeser 10 months ago

  • Status changed from New to Needs Feedback

Why do you want to remove the page parameter? Paginated pages shouldn’t have a canocial to the first page and that is what happens when you remove the parameter.

See https://yoast.com/pagination-seo-best-practices/ for more information

#2 Updated by Patrick Fiedorowicz 10 months ago

Richard Haeser wrote:

Why do you want to remove the page parameter? Paginated pages shouldn’t have a canocial to the first page and that is what happens when you remove the parameter.

You are right, Google said that the canonical tag should also include paginated pages.
But most seo tools complain about duplicate titles of the news list and paginated pages. So I would prefer to remove them from canonical tag.

But I can give you another example:
If you use news with categories (article can be related to multiple categories) and use them for filtering, you have to remove the category parameter from canonical tag to prevent duplicate content.

#3 Updated by Richard Haeser 8 months ago

  • Status changed from Needs Feedback to New

#4 Updated by Christoph Hendreich 8 months ago

#5 Updated by Lidia Demin about 2 months ago

Example use case, where parameters shouldn't be added to canonical tag

There is an element that displays individually share-able content blocks. Therefore parameters are attached to the page url the content block is displayed on. If such a content block is shared, the og-tags fetched from the parametric url contain information of the content block and not of the page it's on, but the canonical tag should be the same as the target page still displays the same content.

Example code:

<f:for each="{ContentBlocks}" as="ContentBlock">
   <div id="content-block-1">
      <!-- content block content here -->
      <a href="https://www.facebook.com/sharer/sharer.php?u={f:uri.action(
          pluginName: 'ContentBlockSlider',
          controller: 'ContentBlock',
          action: 'ContentBlockSlider',
          arguments: '{contentBlock: contentBlock}', absolute: 1
       )}">Share me</a>
   </div>
</f:for>

The controller action then overrides the according meta tags. if a $contentBlock argument was provided.

There were several use cases where we had to use this approach to share different contents on one page.

#6 Updated by Richard Haeser 17 days ago

  • Parent task set to #89797

#7 Updated by Richard Haeser 13 days ago

  • Status changed from New to Closed

For both cases you could use the hook in TYPO3 v9 or the PSR-14 event ModifyUrlForCanonicalTagEvent in v10.2+

You can add your own logic and set the canonical link you want. Be aware that the canonical is using all relevant parameters that are used for cHash calculation as well. If a parameter is not necessary for a canonical url, you also might want to check if it is necessary for cHash calculation.

Also available in: Atom PDF