brotkrueml / schema

TYPO3 extension providing an API and view helpers for schema.org markup

Home Page:https://extensions.typo3.org/extension/schema

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only generate breadcrumb automatically in case there is none, yet

ohader opened this issue · comments

Current behavior

When having extension configuration automaticBreadcrumbSchemaGeneration enabled, and a breadcrumb has already been provided via Fluid <schema:type.BreadcrumbList>...</schema:type.BreadcrumbList>, AddBreadcrumbList would override the breadcrumb again.

Expected behavior/output

AddBreadcrumbList should only inject a breadcrumb in case there's non yet.

Steps to reproduce

  • enable extension configuration automaticBreadcrumbSchemaGeneration
  • adjust Fluid template (that will be rendered during the request)
    <schema:type.BreadcrumbList>
      <schema:type.ListItem -as="itemListElement" position="1" name="Test" item="/" /> 
    </schema:type.BreadcrumbList>
  • clear caches (flush ext:schema cache) and reload page

Environment

  • schema version: 2.6.5-dev, dev-main commit 96af074
  • TYPO3 version(s): 11.5.21
  • Is your TYPO3 installation set up with Composer (Composer Mode): yes

@ohader Thanks for the issue. I can't reproduce the overriding, however, the breadcrumb from the template is added, so you now have the automatically generated breadcrumb and the one from the template, for example:

{
  "@context":"https://schema.org/",
  "@graph":[{
    "@type":"WebPage",
    "breadcrumb":[{
      "@type":"BreadcrumbList",
      "itemListElement": {
        "@type":"ListItem",
        "item":"/",
        "name":"Test",
        "position":"1"
      }
    }, {
      "@type":"BreadcrumbList",
      "itemListElement":{
        "@type":"ListItem",
        "item":{
          "@type":"WebPage",
          "@id":"/blog"
        }
      }
    }]
  }]
}

I would define this as correct behaviour, as multiple breadcrumbs are possible:
https://developers.google.com/search/docs/appearance/structured-data/breadcrumb?hl=en#html_example

What do you think?

Sorry, I got the original description wrong. Indeed it was NOT overridden, but I got two conflicting BreadCrumbLists. In my scenario the auto-generation is fine for regular pages, but for plugins rendering additional aspects, I was aiming for a possibility to avoid auto-generation and use a custom breadcrumb generation.

Example: https://indiemusik-festival.de/events/festival-2023/act/aetna (uses the patch of PR #105 already)

  • /events is from pages table
  • /events/festival-2023 is an Extbase Entity
  • /events/festival-2023/act/aetna is an additional (nested) Extbase Entity

As multiple breadcrumbs are possible, the given PR may be breaking for a user who relies on them. I was aware of multiple breadcrumbs when implementing them, so it is a feature.

I can think of a new extension configuration "Allow only one breadcrumb list". If this is set, the last added one wins. The problem is not bound only to the automatic embedding of the breadcrumb, but also when one adds the breadcrumb via the Fluid layout and wants to override it in a specific extension template.

This way, the SchemaManager does the work: If the setting is activated, just override everytime the breadcrumbLists property. Otherwise, add it to the list. There are some edge cases to consider, for example, it is possible to set a webpage type with one or more breadcrumbs.

This would solve your issue, I think?

I'll give it a try with multiple breadcrumbs... let's see how Google handles them finally in their index.
The preview looks okay https://search.google.com/test/rich-results/result?id=NY0TXQnHASXR3DE0RCciUA

Closing this issue, probably will reopen at a later time again...

@ohader I added a new configuration setting "Allow only one breadcrumb list" to the extension settings. - currently in branch 2.7.x-dev (main).