Skip to content

Instantly share code, notes, and snippets.

@piotrpog
Last active August 15, 2020 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrpog/a1584dc8f3e8762b4f7350242135e64c to your computer and use it in GitHub Desktop.
Save piotrpog/a1584dc8f3e8762b4f7350242135e64c to your computer and use it in GitHub Desktop.
Breadcrumb template component for Craft CMS based on Seomatic plugin. More info on http://craftsnippets.com/articles/breadcrumb-created-from-url-for-craft-cms
{% v2 %}
% set breadcrumbLinks = seomatic.jsonLd.get('breadcrumbList').itemListElement %}
{% if breadcrumbLinks|length > 1 %}
<nav class="breadcrumb" aria-label="{{'breadcrumbs'|t}}">
<ul>
{% for link in breadcrumbLinks %}
<li class="{{loop.last ? 'is-active'}}" {{loop.last ? 'aria-current="page"'}}>
<a href="{{ link.item['@id'] }}">
<span itemprop="name">{{ link.item['name'] }}</span>
</a>
<meta itemprop="position" content="{{loop.index}}" />
</li>
{% endfor %}
</ul>
</nav>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment