Problem/Motivation

CustomElementsMetatagsGenerator::getMetatags() only looks at the node route parameter. For any other content entity route, e.g. taxonomy terms, Canvas pages or other entity types with Metatag defaults, the custom elements response carries empty metatags. The HTML output of the same route does have title, description, canonical link and Open Graph tags, because Metatag supports every content entity type. A decoupled frontend therefore loses all metatags on non-node pages.

Steps to reproduce

  1. Enable Metatag and lupus_ce_renderer, with Metatag defaults for taxonomy terms (e.g. the global defaults).
  2. Create a taxonomy term.
  3. Request /taxonomy/term/{id}?_format=custom_elements.
  4. The response has metatags.meta without the term's title and metatags.link without a canonical link. The same request for a node returns both.

Proposed resolution

Fix and add tests

Remaining tasks

  • Review.

User interface changes

None.

API changes

New protected method CustomElementsMetatagsGenerator::getRouteEntity().

AI disclosure

This issue and the patch were drafted with AI assistance (Claude Code). A maintainer reviewed and tested the change before posting.

Command icon 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

fago created an issue. See original summary.

fago’s picture

Status: Active » Needs review

I figured this was missing and we had patched this internally for a while to support canvas. Time to fix that upstream. Created MR!

  • fago committed 61be1fb9 on 2.x
    fix: #3629041 Metatags are only generated for nodes; other entity routes...
fago’s picture

Status: Needs review » Fixed

this works reliably, code is good and tested, merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.