Issue #3272202 introduced the possibility to fill a tag with <none> which prevents inheritance and clear the value.
It works well unless for the `canonical` and `shortlink` tags. The reason is that Drupal Core set these tags by default (see EntityViewController::view()).
In _metatag_remove_duplicate_entity_tags() invoked by metatag_entity_view_alter(), we unset the values set by the Core only if Metatags is overriding the values. <none> is translated to empty and not considered as a replacement. The default Drupal Core tags are displayed.
Expected output:
Canonical and shortlink tags are removed if set to <none>.
Fixing this bug would give a workaround to #3247275.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3631058 after.png | 44.48 KB | csakiistvan |
| #7 | 3631058 before.png | 111.65 KB | csakiistvan |
Issue fork metatag-3631058
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
vbouchetComment #3
wkr1shna commentedComment #5
wkr1shna commentedI've addressed the CSpell and PHPCS issues reported by the initial CI run in the latest commit.
The change handles `` for canonical and shortlink tags independently, preserves the existing duplicate-removal behavior for normal overrides, and includes Kernel and Functional test coverage.
The Kernel test passed in the previous CI run. The latest pipeline is being checked for the follow-up changes.
Please review and let me know if any further changes are needed.
Comment #6
csakiistvanComment #7
csakiistvan✅ Tested and works — with Canonical URL and Shortlink set to
<none>in the Content defaults, a new article still output both<link rel="canonical">and<link rel="shortlink">on 2.2.x; after checking out MR !277 as-is (not rebased on current 2.2.x) and rebuilding caches, both tags are gone from the page source.<none>now removes the core-provided tags as the issue expects.Comment #8
csakiistvanComment #10
damienmckennaThis is an unnecessary change:
I'm going to revert that part and see how it works.
Comment #11
damienmckennaCorrection - the change is needed to make it work.
Comment #12
damienmckennaComment #14
damienmckennaCommitted, Thank you.