6

How do you create breadcrumbs based on a structure?

My structure:

  • Parent
    • Child (active)
    • Other Child

Child

My url:

site.com/parent/child

So my breadcrumb need to be:

home (url) / parent (url) / child

13

Got it!

{% if craft.request.segments %}
<nav class="breadcrubs">
    <div class="container">
        <div class="row">
            <ol class="breadcrumb">
                <li><a href="{{ siteUrl }}">Home</a></li>
                {% for crumb in entry.getAncestors() %}
                    <li>{{ crumb.getLink() }}</li>
                {% endfor %}
                <li>{{ entry.title }}</li>
            </ol>
        </div>
    </div>
</nav>
{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.