{# Breadcrumb snippet for improved view @ google#}
{# For "offscreen"-reference/layout independent, disabled
<div style="position:absolute;width:0;height:0;max-width:0;max-height:0;overflow:hidden">
#}
<ul class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">
{# The first item should be your home #}
<li property="itemListElement" typeof="ListItem">
<a href="{{ siteUrl }}" property="item" typeof="WebPage">
<span property="name" class="hidden">{{ siteName }}</span>
</a>
<meta property="position" content="1">
</li>
{# Check if the current page has parents #}
{% set crumbs = entry.ancestors|default([]) %}
{% if crumbs|length %}{% for crumb in crumbs %}
<li property="itemListElement" typeof="ListItem">
<a href="{{ crumb.url }}" property="item" typeof="WebPage">
<span property="name">{{ crumb.title }}</span>
</a>
<meta property="position" content="{% set lastLevel = (crumb.level + 1) %}{{ (crumb.level + 1) }}">
</li>
{% endfor %}{% endif %}
{# Display the current page #}
{% if entry is defined %}
<li property="itemListElement" typeof="ListItem">
<a href="{{ entry.url }}" property="item" typeof="WebPage">
<span property="name">{{ entry.title ) }}</span>
</a>
<meta property="position" content="{{ (lastLevel + 1) }}">
</li>
{% else %}
{# ? #}
{% endif %}
</ul>
{# Don't forget to close the "offscreen"-div if you've used ;)
</div>
#}
If you want to implement Rich Snippet Breadcrumbs for your Craft CMS powered website, you can use this snippet. Even if you don't want to show the breadcrumbs in your layout, this snippet gives your website a nicer breadcrumb list in Google results :)
Updated 21-1-2016
Updated 21-1-2016
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.