Add <none> placeholder to clear / unset inherited value

Created on 29 March 2022, over 2 years ago
Updated 4 November 2024, 18 days ago

Problem/Motivation

Metatags uses inheritance to, for example, set global defaults > node defaults > node type values.
This is very flexible, helpful and also allows overriding inherited values with other strings or tokens.

But one thing you currently can't do (or it's not well documented in the UI) is to override an inherited value with NULL. This is for example a problem if "canonical" is set to [current-page:url:absolute] which means also on NOT FOUND (403) pages the canonical is being output, which is incorrect (at least SEO crawlers complain).
This concrete issue was also pointed out here: #3247275: Remove canonical for 404 and 403 pages β†’

But also in other cases, you may want to REMOVE / UNSET an inherited value.

Steps to reproduce

See above.

Proposed resolution

Define a fixed (or configurable with default) value which is a placeholder for UNSET.

My suggestion would be to use <none> as Drupal uses this in other places. If it's important for anyone that the string "" can be a metatag value (and it's a rare case), we could make that value also editable. But I think it can be a constant.
Another alternative would be to use a checkbox, but that would bloat configuration and would also be less intuitive.

If a metatag has a <none> value, unset it when handling the metatag and do not output the metatag.

Document the behavior in the general description or metatag field description.

A further combined improvement would be to show the inherited value in the inherited metatags, see ✨ Inherit parent metatags as placeholder in override forms Active . And / or only show the <none> documentation below in these cases.
Of course should always be allowed, even if there is no inherited value and in such case also behave like the field was left empty.

Remaining tasks

  1. Discuss
  2. Create MR with implementation & documentation
  3. Review & Test
  4. Release

User interface changes

API changes

Data model changes

✨ Feature request
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @damienmckenna just came back here for the same needs. The question is, do you think it will be realistic to implement the full featured override solution within the next decade? :D (Not asking you do do so or something like that, this is really meant to read with a smile).

    My thought is the following:
    I think needing to clear a predefined default in an override is clearly an edge-case.
    It already works for any kind of string, it's just not possible to unset a value at higher level, because clearing the value would bring back the defaults. And entering a space would (hopefully) just set a space for the metatag value.

    So if we'd allow a special string like
    <unset>
    <empty>
    <none>
    for technical users, we could quite simply extend the overriding to this remaining case.
    And we could still convert that into checkboxes one day, if anyone solves it.

    If you should change your opinion on this, our team would be happy to implement that, as we're running into this again and again.

    Implementing the full-featured checkbox solution is great, but a big bunch of work and risky to never getting done.
    This might be just "good enough" and fit things like Drupals magic "code> placehoder.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Reopening this as a simpler solution that won't involve greatly expanding the DOM structure and JS logic on edit forms.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    So something like this might work, maybe?

Production build 0.71.5 2024