I've enabled the checkbox "Add current breadcrumb as structured data."
But I don't see the structured data in the source code.

What am I missing here?

Comments

Dennis Cohn created an issue. See original summary.

greg boggs’s picture

It should add a json-ld tag at the top

ankitjhakal’s picture

Assigned: Unassigned » ankitjhakal
ankitjhakal’s picture

Hi All, i am able to see breadcrumb schema in head tag of the page. We just need to check this checkbox. Below code is responsible to add schema.

function easy_breadcrumb_preprocess_block(&$variables) {

  if($variables['plugin_id'] == 'system_breadcrumb_block') {
    // Get JSON-LD.
    if ($json_ld = \Drupal::service('easy_breadcrumb.structured_data_json_ld')
      ->value()) {

      // Prepare script tag.
      $structured_data = [
        '#tag'        => 'script',
        '#attributes' => ['type' => 'application/ld+json'],
        '#value'      => $json_ld,
      ];

      // Add script tag.
      $variables['#attached']['html_head'][] = [
        $structured_data,
        'easy_breadcrumb_structured_data_json_ld',
      ];
    }
  }
}

You can debug through it, what's wrong with you.

ankitjhakal’s picture

Assigned: ankitjhakal » Unassigned
Status: Active » Closed (works as designed)

Changing status for now. Reopen it if you did not get your answer.

joe huggans’s picture

This happens if you use {{ drupal_breadcrumb() }} in twig to print the breadcrumbs, which bypasses the block preprocess function that is what includes the schema data.

It works if you use {{ drupal_block('system_breadcrumb_block') }} instead.