Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Its possible for 2 regions to have the same alternate url:
<link rel="alternate" hreflang="en-de" href="https://site.com/germany-austria/en/">
<link rel="alternate" hreflang="en-at" href="https://site.com/germany-austria/en/">
The current implementation in HtmlResponseAttachmentsProcessor::processHtmlHeadLink
generates a key that is used for rendering which uses only the href as unique key.
Because of this the second alternate url overwrites the first one and is not rendered.
Comment | File | Size | Author |
---|---|---|---|
#23 | core-hreflang_multiple_same_links_for_xdefault-2945033-23.patch | 3.04 KB | vdsh |
#21 | interdiff.2945033.12-21.txt | 761 bytes | longwave |
#21 | 2945033-21.patch | 3.04 KB | longwave |
#12 | 2945033-12-test-only.patch | 2.01 KB | longwave |
Issue fork drupal-2945033
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
yobottehg CreditAttribution: yobottehg commentedAttached is a patch that specialcases alternate urls.
Comment #4
yobottehg CreditAttribution: yobottehg commentedmore specific about the used parameters
Comment #5
borisson_Comment #7
raphaeltbm CreditAttribution: raphaeltbm commentedComment #9
jlatorre CreditAttribution: jlatorre commentedUpdate patch to Drupal 8.7.x branch
Comment #11
Elendev CreditAttribution: Elendev at Swissquote commentedHi @yobottehg or @jlatorre, I'm encountering the same issue. Do you need some help to test your patch?
Comment #12
longwaveComment #16
Mirroar CreditAttribution: Mirroar at werk21 commentedI can confirm that #12 works for me and fixes the problem. Tests have passed as well, it seems, so I'd like to say RTBC.
Comment #17
catchShould we be allowing hreflang even without rel = 'alternate'? I think this is legal even if it's rarely used?
Comment #18
DanielVezaApplied #12 to a site where I had the bug where I could not set the x-default and the en-us hreflang links to be the same.
Worked correctly and saw the right output after the patch.
I did a bit of searching around and couldn't find any examples of hreflang used without rel=alternate in the
<head>
. Considering that and the fact tests are passing I'm happy to mark this RTBC.Happy to be overridden though!
Comment #19
longwaveThe current HTML working spec seems to indicate that hreflang is valid for any relation type.
https://html.spec.whatwg.org/multipage/semantics.html#providing-users-wi... doesn't specify the relationships that hreflang is valid for, and just says the link element "could include" hreflang for any link.
rel="help"
is not widely used but is included in the spec, I could imagine there may be context sensitive help available in different languages, for example.Comment #20
catchYeah I think we should allow what's valid according to the spec here rather than limit it to the one common usage.
Comment #21
longwaveAddressed #17-20 by removing the explicit check for
rel="alternate"
.Comment #23
vdsh CreditAttribution: vdsh as a volunteer commentedPatch #21 rerolled for 9.2.3
Comment #27
vdsh CreditAttribution: vdsh as a volunteer commentedComment #28
alexverb CreditAttribution: alexverb at iO commentedSolves the issue (for me in relation to: https://www.drupal.org/project/hreflang/issues/3126993). Putting on RTBC.
Comment #29
alexpottCommitted and pushed 8f497e0a43 to 9.3.x and c1cc0d5c5d to 9.2.x. Thanks!
This is a bug not a feature :) - backported to 9.2.x because it is a low-risk bug fix.
Comment #32
mfbNot directly related to this issue, but I was looking at this code and opened #3245895: Link HTTP header should not be HTML-encoded - I don't think it's correct that core has been HTML-encoding the URL in the Link HTTP header.