Hreflang on non-canonical content pages

Created on 5 August 2021, over 3 years ago
Updated 15 February 2024, 9 months 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

Choose one of the proposed solutions. The current patch #14 is Option A (adding cache context); however 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 work

Version

11.0 πŸ”₯

Component
Content translationΒ  β†’

Last updated 3 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

Comments & Activities

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Not sure how often accessibility meets.

    But there are two proposed solutions can it be highlighted which was chosen please.

  • πŸ‡ΊπŸ‡ΈUnited States themarkahrens

    One potential challenge with this would be when not all content is translated across all languages. For example, if on a US site you had 17 pages of articles but on the CA site there were only 5, what would the appropriate hreflang tags be on ?page=17 of the US site?

  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    @mytungsten That is also a challenge outside of this issue, as if a site uses the built-in language switcher block, then they will get switch links that include such query arguments.

    @smustgrave As far as which proposed solution was chosen, option B seemed like a good idea to me for cache efficiency reasons, but there is no patch for option B as of yet. So I'd say this issue probably needs both review to determine a solution, and a new patch/MR to be developed.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco
  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Reading the 2 options like the idea of using lazy builder too. Moving to NW for that patch.

  • πŸ‡ͺπŸ‡ΈSpain paucala

    Hi everyone, I have update to the last version of core (10.2.3) and it seems that the patch does'nt apply anymore. Any idea?

  • πŸ‡¨πŸ‡­Switzerland aerzas

    Re-rolled patch #14 against Drupal 10.2.3

Production build 0.71.5 2024