
Upgrade Your Drupal Skills
We trained 1,000+ Drupal Developers over the last decade.
See Advanced Courses NAH, I know EnoughHow to add metadata to your breadcrumbs in Drupal 8
I have created a video explaining how you can add breadcrumb metadata to your Drupal 8 website. It quickly explains how to add the metadata to your theme and how you test the results.
If you don't need the explanations and details, feel free to just copy the code below.
You will need a twig template in your theme that overwrites the standard breadcrumb twig template. The name has to be "breadcrumb.html.twig".
Creating the file you can use the following code to have the metadata included in the Microdata format.
{#
/**
* @file
* Theme override for a breadcrumb trail.
*
* Available variables:
* - breadcrumb: Breadcrumb trail items.
*/
#}
{% if breadcrumb %}
{% endif %}
Make sure to test your changes in Google's structured data testing tool:
https://search.google.com/structured-data/testing-tool
More information regarding breadcrumb metadata can be found on
https://developers.google.com/search/docs/data-types/breadcrumbs
Here you have the tutorial. We hope you enjoy it!
About Drupal Sun
Drupal Sun is an Evolving Web project. It allows you to:
- Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
- Facet based on tags, author, or feed
- Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
- View the entire article text inline, or in the context of the site where it was created
See the blog post at Evolving Web