Feature #88242

Make canonical optional

Added by Christoph Hendreich 7 months ago. Updated about 1 month ago.

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

100%

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 optional Closed 2018-10-02
Related to TYPO3 Core - Bug #87760: Option to remove params from canonical tag Closed 2019-02-21

Associated revisions

Revision b594b0aa (diff)
Added by Richard Haeser about 1 month ago

[DOCS] Add hints to disable rendering hreflang and canonical tags

In some edge cases you may want to disable rendering of hreflang and
canonical links. We added some hints how to disable the rendering of
these tags.

Resolves: #88242
Resolves: #88140
Releases: master, 9.5
Change-Id: I197062de0031fc1bb3a21eb84ab124d3d0967f20
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62122
Tested-by: Daniel Siepmann <>
Tested-by: TYPO3com <>
Tested-by: Sybille Peters <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Daniel Siepmann <>
Reviewed-by: Sybille Peters <>
Reviewed-by: Andreas Fernandez <>

Revision 85231603 (diff)
Added by Richard Haeser about 1 month ago

[DOCS] Add hints to disable rendering hreflang and canonical tags

In some edge cases you may want to disable rendering of hreflang and
canonical links. We added some hints how to disable the rendering of
these tags.

Resolves: #88242
Resolves: #88140
Releases: master, 9.5
Change-Id: I197062de0031fc1bb3a21eb84ab124d3d0967f20
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62069
Tested-by: TYPO3com <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Andreas Fernandez <>

History

#1 Updated by Christoph Hendreich 7 months ago

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

#2 Updated by Christoph Hendreich 7 months ago

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

#3 Updated by Richard Haeser 7 months 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 7 months 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 7 months 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 months 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 1 month 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 1 month 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 1 month 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 1 month ago

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

Also available in: Atom PDF