Problem/Motivation

Currently the Free Schema.org tree can only be defined per entity: editors have to build (or import) the tree on every node or taxonomy term. On sites with many entities of the same bundle this is repetitive and error-prone, even though the structure is usually the same for all of them (e.g. every `event` node is an `Event` with the same properties, and every term of the `topics` vocabulary is a `DefinedTerm` or `CollectionPage`), and only the values change.

Since tree values already accept tokens (`[node:title]`, `[term:name]`, `[node:url:absolute]`...), a single tree defined once per bundle would be enough to produce correct JSON-LD for all its entities.

Proposed resolution

Add a bundle-level **default tree**, configurable for any fieldable entity bundle (node types, vocabularies and other content entity bundles):

  • Add a "Free Schema.org" section to the bundle edit form (e.g. `/admin/structure/types/manage/{type}`, `/admin/structure/taxonomy/manage/{vocabulary}/overview`), using the same tree editor widget (type/property suggestions, JSON-LD import, token browser).
  • Store the default tree as a third-party setting of the bundle config entity (`free_schema` key), so it is exportable with configuration management and translatable via config translation.
  • At render time, the JSON-LD for an entity is resolved as follows:
    1. If the entity has its own value in a Free Schema.org field, use it (current behaviour).
    2. Otherwise, if its bundle has a default tree, use it, replacing tokens with the current entity.
    3. Otherwise, do nothing (other JSON-LD on the page is left untouched).
  • The default tree replaces every other JSON-LD on the page, exactly like a per-entity tree.
  • Editing the default tree requires the existing restricted permission (or a new "Administer free Schema.org defaults" permission).
  • Optionally, show the inherited default as a read-only preview / starting point in the entity widget, so editors can see what will be printed and copy it to override it.
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

pascuperbla created an issue. See original summary.

jasa made their first commit to this issue’s fork.

  • jasa committed 816c8e4d on 1.0.x
    Issue #3632333: Allow a default Schema.org tree per bundle
    

jasa’s picture

Status: Active » Fixed

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.

Status: Fixed » Closed (fixed)

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