Skip to content

Instantly share code, notes, and snippets.

@vuchkov
Forked from thejimbirch/breadcrumb.html.twig
Created October 7, 2021 13:35
Show Gist options
  • Save vuchkov/2e6c7eeea28a65c7abf383a023fd4def to your computer and use it in GitHub Desktop.
Save vuchkov/2e6c7eeea28a65c7abf383a023fd4def to your computer and use it in GitHub Desktop.

Revisions

  1. @thejimbirch thejimbirch created this gist Apr 13, 2020.
    31 changes: 31 additions & 0 deletions breadcrumb.html.twig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    {#
    /**
    * @file
    * Theme override for a breadcrumb trail.
    *
    * Available variables:
    * - breadcrumb: Breadcrumb trail items.
    */
    #}
    {% if breadcrumb %}
    <ol itemscope itemtype="http://schema.org/BreadcrumbList" class="breadcrumbs" aria-label="breadcrumb">
    {% for item in breadcrumb %}
    <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
    {% if item.url %}
    <a itemprop="item" href="{{ item.url }}">
    <span itemprop="name">{{ item.text }}</span>
    <meta itemprop="position" content="{{ loop.index }}" />
    </a>
    {% else %}
    <span itemprop="item">
    <span itemscope itemprop="identifier" itemtype="http://schema.org/PropertyValue" hidden>
    <meta itemprop="url">{{ url('<current>') }}</span>
    </span>
    <span itemprop="name">{{ item.text }}</span>
    <meta itemprop="position" content="{{ loop.index }}" />
    </span>
    {% endif %}
    </li>
    {% endfor %}
    </ol>
    {% endif %}