<p>If your categories are only one level deep, you could hard-code the breadcrumbs into the category template:</p>

<pre><code>{% block breadcrumb %}
  &lt;ul class="breadcrumbs"&gt;
    &lt;li&gt;&lt;a href="{{ siteUrl }}"&gt;Blog&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;{{ category.title }}&lt;/li&gt;
  &lt;/ul&gt;
{% endblock %}
</code></pre>

<p>In <code>_layout.html</code> you would have:</p>

<pre><code>{% block breadcrumb %}
  &lt;ul class="breadcrumbs"&gt;
    &lt;li&gt;&lt;a href="{{ siteUrl }}"&gt;Blog&lt;/a&gt;&lt;/li&gt;
    {% if craft.request.segments %}
      {% for crumb in entry.getAncestors() %}
        &lt;li&gt;{{ crumb.getLink() }}&lt;/li&gt;
      {% endfor %}
      &lt;li&gt;{{ entry.title() }}&lt;/a&gt;&lt;/li&gt;
    {% endif %}
  &lt;/ul&gt;
{% endblock %}
</code></pre>

<p>Haven't tried this myself, but I think it would work - the category template would override the layout. </p>

<p>Of course, if you have multiple levels of categories, the intermediate levels won't be included, so it's not an ideal solution.</p>

CC BY-SA 3.0
2016-09-02T23:02:30.403Z
2016-09-02T23:02:30.403Z
Katie Fritz
<p>I'm a Craft first-timer building a simple blog site. I want to include breadcrumbs at the top of each page like so:</p>

<blockquote>
  <p>siteurl.com: [Blog]</p>
  
  <p>siteurl.com/category/example-category: [Blog > Example Category]</p>
  
  <p>siteurl.com/post/2015/entry-title: [Blog > Entry Title]</p>
</blockquote>

<p>I've found this snippet which correctly outputs the breadcrumb for the entry permalink page:</p>

<pre><code>&lt;ul class="breadcrumbs"&gt;
    &lt;li&gt;&lt;a href="{{ siteUrl }}"&gt;Blog&lt;/a&gt;&lt;/li&gt;
    {% if craft.request.segments %}
        {% for crumb in entry.getAncestors() %}
           &lt;li&gt;{{ crumb.getLink() }}&lt;/li&gt;
        {% endfor %}
        &lt;li&gt;{{ entry.title() }}&lt;/a&gt;&lt;/li&gt;
    {% endif %}
&lt;/ul&gt;
</code></pre>

<p>But I also need something that will include a crumb for when the visitor is on a category page.</p>

<p>So far, my templates are structured like so:</p>

<pre><code>templates/
 | index.html
 | _layout.html
 | posts/
    | index.html
    | category.html
    | _entry.html
</code></pre>

<p>Where the breadcrumb snippet is included in '_layout.html'.</p>

<p>In EE, I would just check my segments and use Low Seg2Cat to grab the category title. Is there an equivalent to this process in Craft? Or is it handled completely differently?</p>

CC BY-SA 3.0
2016-09-02T22:52:49.943Z
did you ever find a solution for this?
Katie Fritz
<templating><categories><navigation>
Breadcrumbs for category pages
# Breadcrumbs for category pages

(Asked by: username_0 on 2015-12-10)

I'm a Craft first-timer building a simple blog site. I want to include breadcrumbs at the top of each page like so:

siteurl.com: [Blog]
siteurl.com/category/example-category: [Blog > Example Category]
siteurl.com/post/2015/entry-title: [Blog > Entry Title]

I've found this snippet which correctly outputs the breadcrumb for the entry permalink page:

    Blog
    {% if craft.request.segments %}
        {% for crumb in entry.getAncestors() %}
           {{ crumb.getLink() }}
        {% endfor %}
        {{ entry.title() }}
    {% endif %}


But I also need something that will include a crumb for when the visitor is on a category page.
So far, my templates are structured like so:
templates/
 | index.html
 | _layout.html
 | posts/
    | index.html
    | category.html
    | _entry.html

Where the breadcrumb snippet is included in '_layout.html'.
In EE, I would just check my segments and use Low Seg2Cat to grab the category title. Is there an equivalent to this process in Craft? Or is it handled completely differently?

**Tags:** templating, categories, navigation
> **Comments:**
> **username_1**: did you ever find a solution for this?  

---

## 1 answers

### Answer by username_1 on 2016-09-02. Score: 2

If your categories are only one level deep, you could hard-code the breadcrumbs into the category template:
{% block breadcrumb %}
  
    Blog
    {{ category.title }}
  
{% endblock %}

In _layout.html you would have:
{% block breadcrumb %}
  
    Blog
    {% if craft.request.segments %}
      {% for crumb in entry.getAncestors() %}
        {{ crumb.getLink() }}
      {% endfor %}
      {{ entry.title() }}
    {% endif %}
  
{% endblock %}

Haven't tried this myself, but I think it would work - the category template would override the layout. 
Of course, if you have multiple levels of categories, the intermediate levels won't be included, so it's not an ideal solution.


---

