Hreflang on non-canonical content pages

Created on 5 August 2021, over 3 years ago
Updated 4 February 2023, about 2 years ago

Problem/Motivation

When Content Translation module adds hreflang link tags to an entity page that is not the canonical URL, e.g. when query arguments are present, the page no longer has the self-referencing hreflang tag that is expected by search engines. I.e. the query string is expected to be appended to the href attribute URL.

Steps to reproduce

I have the node page, which renders a view listing with facets.
When some facet is applied, the canonical is pointed to the original node page.
Hreflang also points to the original node page, it cause the error "No self-referencing hreflang".

Proposed resolution

Option A: Add query arguments to the hreflang link tags, and add query arguments to the cache context. This allows the dynamic page cache to set a unique cache for each set of query arguments.

Option B: To improve cache efficiency, use lazy builder placeholders to add query arguments to the hreflang link tags. At present, HtmlResponseAttachmentsProcessor::processHtmlHeadLink() doesn't really contemplate this; it uses 'html_head_link:...' identifiers (that contain the href attribute) to merge duplicate link tags.

Remaining tasks

The current patch #14 is Option A (adding cache context); it seems like a good idea to develop an Option B patch that instead uses lazy builder placeholders for better cache efficiency?

User interface changes

None

API changes

Possibly a sort-of minor API change if link tags use lazy builder placeholders.

Data model changes

None

🐛 Bug report
Status

Needs review

Version

10.1

Component
Content translation 

Last updated 9 days ago

No maintainer
Created by

🇷🇺Russia kiseleva.t

Live updates comments and jobs are added and updated live.
  • Needs accessibility review

    Used to alert the accessibility topic maintainer(s) that an issue significantly affects (or has the potential to affect) the accessibility of Drupal, and their signoff is needed (see the governance policy draft for more information). Useful links: Drupal's accessibility standards, the Drupal Core accessibility gate.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024