<p>I think you've made this more complicated that it needs to be for yourself. Reading the Craft docs on <a href="https://craftcms.com/support/breadcrumbs#outputting-the-entrys-ancestors-in-a-structure-section" rel="nofollow">Outputting the Entry’s Ancestors in a Structure Section</a> it looks like you can use the handle <code>.getAncestors()</code> method to output the entries leading up to the currently viewed entry automatically, and have access to their URLs.</p>

<p>Give the example a go.</p>

<pre><code>{% if entry.level &gt; 1 %}
  &lt;ul class="crumbs"&gt;
    {% for crumb in entry.getAncestors() %}
      &lt;li&gt;{{ crumb.getLink() }}&lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
{% endif %}
</code></pre>

CC BY-SA 3.0
2016-07-22T11:09:45.573Z
2016-07-22T11:09:45.573Z
Luke Pearce
<p>I have a structure set up like:</p>

<p><strong>What we do (set as a structure)</strong></p>

<ul>
<li><p>2nd level page A</p>

<pre><code>* 3rd level page A
* 3rd level page A
</code></pre></li>
<li><p>2nd level page B</p>

<pre><code>* 3rd level page B
</code></pre></li>
</ul>

<p>I'm setting up breadcrumbs for this so it's</p>

<p>Home / What we do / 2nd level page A / 3rd level page A</p>

<p>This is what I have so far but I can't figure out how to get the entry section url working (what-we-do) which is set in the Entry Url format.</p>

<pre><code>{% set crumbs = entry.ancestors|default([]) %}
{% if crumbs|length %}
&lt;ul class="breadcrumbs"&gt;
    &lt;li&gt;&lt;a href="{{ siteUrl }}"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="{{ NEED HELP }}"&gt; {{ entry.section.name }}&lt;/a&gt;&lt;/li&gt;
    {% for crumb in crumbs %}
        &lt;li&gt;&lt;a href="{{ crumb.url }}"&gt;{{ crumb.title }}&lt;/a&gt;&lt;/li&gt;
    {% endfor %}
    &lt;li&gt;{{ entry.title }}&lt;/li&gt;
&lt;/ul&gt;
{% endif %}
</code></pre>

CC BY-SA 3.0
2016-07-21T16:12:06.187Z
What does `entry.url` give you?
Luke Pearce
CC BY-SA 3.0
2016-07-22T09:44:07.047Z
The whole URL. I'm after the url that the structure adds to the level above the entry.
sarah3585
CC BY-SA 3.0
2016-07-22T09:49:22.037Z
I'm not sure what you mean? Using `{{ entry.url }}` will link to the section name you output with `{{ entry.section.name }}`.
Luke Pearce
CC BY-SA 3.0
2016-07-22T10:47:11.030Z
{{ entry.url }} gives you the url of the current entry. ie /what-we-do/2nd-level/3rd-level I need just the /what-we-do part for the breadcrumb
sarah3585
<structure><sections>
Get structure url
# Get structure url

(Asked by: username_0 on 2016-07-21)

I have a structure set up like:
What we do (set as a structure)

2nd level page A
* 3rd level page A
* 3rd level page A

2nd level page B
* 3rd level page B


I'm setting up breadcrumbs for this so it's
Home / What we do / 2nd level page A / 3rd level page A
This is what I have so far but I can't figure out how to get the entry section url working (what-we-do) which is set in the Entry Url format.
{% set crumbs = entry.ancestors|default([]) %}
{% if crumbs|length %}

    Home
     {{ entry.section.name }}
    {% for crumb in crumbs %}
        {{ crumb.title }}
    {% endfor %}
    {{ entry.title }}

{% endif %}

**Tags:** structure, sections

> **Comments:**
> **username_1**: What does `entry.url` give you?  
> **username_0**: The whole URL. I'm after the url that the structure adds to the level above the entry.  
> **username_1**: I'm not sure what you mean? Using `{{ entry.url }}` will link to the section name you output with `{{ entry.section.name }}`.  
> **username_0**: {{ entry.url }} gives you the url of the current entry. ie /what-we-do/2nd-level/3rd-level I need just the /what-we-do part for the breadcrumb  

---

## 1 answers

### Answer by username_1 on 2016-07-22. Score: 3 | Accepted answer

I think you've made this more complicated that it needs to be for yourself. Reading the Craft docs on Outputting the Entry’s Ancestors in a Structure Section it looks like you can use the handle .getAncestors() method to output the entries leading up to the currently viewed entry automatically, and have access to their URLs.
Give the example a go.
{% if entry.level > 1 %}
  
    {% for crumb in entry.getAncestors() %}
      {{ crumb.getLink() }}
    {% endfor %}
  
{% endif %}


---

