Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
On Node pages (and perhaps pages for other entities), Drupal core adds a rel="shortlink" link as an attachment to the build array. When the metatag module also adds a shortlink link, this results in two shortlink links. This is not allowed and will cause search engines to ignore the shortlink link(s) altogether.
Proposed resolution
If metatag provides a shortlink link, remove the one provided in the entity's build array.
Remaining tasks
Patch will be attached in the first comment.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#8 | metatag-n2848353-8.patch | 14.46 KB | DamienMcKenna |
| |||
#6 | metatag-n2848353-6.patch | 12.29 KB | DamienMcKenna |
#2 | metatag-duplicated_shortlink-2848353-2.patch | 2.17 KB | grisendo |
|
Comments
Comment #2
grisendo CreditAttribution: grisendo at The NodeHub commentedI attach a patch
Comment #3
grisendo CreditAttribution: grisendo at The NodeHub commentedComment #4
BertrandS CreditAttribution: BertrandS commentedThank you, works perfectly.
Comment #5
DamienMcKennaI was wondering why the existing tests didn't catch this problem, it was because the current tests check for shortlink on a custom route, not an entity path, so core doesn't automatically add the shortlink tag.
Comment #6
DamienMcKennaOk, this extends the existing tag tests to also test an entity, and it does indeed uncover the problem with the shortlink tag.
Comment #8
DamienMcKennaAnd now the two together.
Comment #10
DamienMcKennaHurray! It worked! Committed. Thanks @grisendo!
Comment #11
DamienMcKennaI created a new issue to backport the test changes to D7: #2876629: Extend tag tests to also handle entities