Feature #88242

Make canonical optional

Added by Christoph Hendreich over 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
SEO
Target version:
-
Start date:
2019-04-28
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
canonical
Complexity:
Sprint Focus:

Description

It would be useful to have a TypoScript option which deactivates the generation of the canonical tag or to remove some paramter, like a fixed pagetype.
For example, when using an AMP template using pagetype, AMP output page must have the canonical to the HTML main page.

<link rel="canonical" href="https://www.domain.de/de/page-de/"/>
<link rel="alternate" hreflang="de" href="https://www.domain.de/de/page-de"/>
<link rel="alternate" hreflang="en" href="https://www.domain.de/en/page-en"/>
<link rel="alternate" hreflang="x-default" href="https://www.domain.de/de/page-de/"/>

<link rel="amphtml" href="https://www.domain.de/de/page-de/amp/" />
Alternative with subdomain <link rel="amphtml" href="https://amp.domain.de/de/page-de/" />

https://amp.dev/documentation/examples/guides/internationalization/?format=websites#example-1-canonical-amp
Every AMP document must have a link tag with rel=canonical pointing to its matching canonical desktop document, again, in the same language.


Related issues

Related to TYPO3 Core - Task #86545: Make canonical and hreflang optionalClosedRichard Haeser2018-10-02

Actions
Related to TYPO3 Core - Bug #87760: Option to remove params from canonical tagClosed2019-02-21

Actions
#1

Updated by Christoph Hendreich over 2 years ago

  • Related to Task #86545: Make canonical and hreflang optional added
#2

Updated by Christoph Hendreich over 2 years ago

  • Related to Bug #87760: Option to remove params from canonical tag added
#3

Updated by Richard Haeser over 2 years ago

The chash configuration is used to determine which parameters are used when rendering the link. So all parameters that are relevant to calculate the cHash are kept in generating the url. All other parameters are dropped.

There is a signal slot available where you have the possibility to set the canonical link yourself. You can use the signalName `beforeGeneratingCanonical` for the class `\TYPO3\CMS\Seo\Canonical\CanonicalGenerator`. In that way you can set your own canonical tag and can create the canonical without the type.

I think you can use that for your usecase.

#4

Updated by Richard Haeser over 2 years ago

  • Tracker changed from Task to Feature
  • Status changed from New to Needs Feedback
  • Priority changed from Must have to Could have
  • Target version deleted (next-patchlevel)
#5

Updated by Christoph Hendreich over 2 years ago

Many thanks for the information, we have already implemented this.
In this case we noticed that the canonical and the language data were different.

Example:

<link rel="canonical" href="https://www.domain.de/de/page/amp/">
<link rel="alternate" hreflang="de" href="https://www.domain.de/de/page/">
<link rel="alternate" hreflang="en" href="https://www.domain.de/de/page/">
<link rel="alternate" hreflang="x-default" href="https://www.domain.de/de/page/">

If so, should everything run the same for both parameters?

I think it would make sense anyway to present a way to disable this directly via TS.
Thus there are still further possibilities of the adjustment directly over Pagetype in the TS.
Because a canonical can also be rendered and output via VHS and an on and off switch would be the most efficient here, I think.

    page.config {
        canonical = 0
        hreflang = 0
    }
#6

Updated by Peter Linzenkirchner about 2 years ago

I would strongly support the solution with typoscript. I am updating an number of old TYPO3 installations end ends up with many duplicate canonicals.

#7

Updated by Gerrit Code Review about 2 years ago

  • Status changed from Needs Feedback 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/+/62122

#8

Updated by Gerrit Code Review about 2 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/+/62122

#9

Updated by Gerrit Code Review about 2 years ago

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

#10

Updated by Richard Haeser about 2 years ago

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

Updated by Benni Mack almost 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF