Displaying Breadcrumbs for an Entry
There are a couple ways to output a list of breadcrumbs for an entry depending on how your site’s built.
Outputting the Entry’s Ancestors in a Structure Section #
If your entry is within a Structure section and you want to output the actual trail of entries leading up to the current entry, you can do that by looping through the entry’s ancestors:
{% if entry.level > 1 %}
<ul class="crumbs">
{% for crumb in entry.getAncestors() %}
<li>{{ crumb.getLink() }}</li>
{% endfor %}
</ul>
{% endif %}
Outputting a Custom List of Entries #
If your entry is not within a Structure section, or you want to give it a custom list of breadcrumbs, you can do that by creating an Entries field called “Breadcrumbs”, and assigning it to your entry’s section. After you’ve done that and re-saved your entry with breadcrumb entries selected, you can output your breadcrumbs by looping through that field’s value:
{% if entry.breadcrumbs | length %}
<ul class="crumbs">
{% for crumb in entry.breadcrumbs %}
<li>{{ crumb.getLink() }}</li>
{% endfor %}
</ul>
{% endif %}