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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

grisendo created an issue. See original summary.

grisendo’s picture

grisendo’s picture

Status: Active » Needs review
BertrandS’s picture

Thank you, works perfectly.

DamienMcKenna’s picture

I 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.

DamienMcKenna’s picture

Ok, this extends the existing tag tests to also test an entity, and it does indeed uncover the problem with the shortlink tag.

Status: Needs review » Needs work

The last submitted patch, 6: metatag-n2848353-6.patch, failed testing.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
14.46 KB

And now the two together.

  • DamienMcKenna committed 1373c87 on 8.x-1.x authored by grisendo
    Issue #2848353 by DamienMcKenna, grisendo: Only output one shortlink tag...
DamienMcKenna’s picture

Status: Needs review » Fixed
Parent issue: » #2563615: Plan for Metatag 8.x-1.1 release

Hurray! It worked! Committed. Thanks @grisendo!

DamienMcKenna’s picture

I created a new issue to backport the test changes to D7: #2876629: Extend tag tests to also handle entities

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.