<p>You can use the <code>level</code> method to determine which iteration of the nav you are on and change the behavior:</p>

<pre><code>&lt;ul&gt;
    {% set pages = craft.entries.section('page') %}
    {% nav page in pages %}
        &lt;li&gt;
            {% if page.level == 1 %}
                &lt;a href="/"&gt;{{ page.title }}&lt;/a&gt;
            {% else %}
                {{ page.getLink() }}
            {% endif %}
            {% ifchildren %}
                &lt;ul&gt;
                    {% children %}
                &lt;/ul&gt;
            {% endifchildren %}
        &lt;/li&gt;
    {% endnav %}
&lt;/ul&gt;
</code></pre>

<p>of if it's only one particular entry, then you can create a conditional to check for that entry (using slug, id, title, or any other attribute or field value).</p>

<pre><code>&lt;ul&gt;
    {% set pages = craft.entries.section('page') %}
    {% nav page in pages %}
        &lt;li&gt;
            {% if page.slug == "myPage" %}
                &lt;a href="/"&gt;{{ page.title }}&lt;/a&gt;
            {% else %}
                {{ page.getLink() }}
            {% endif %}
            {% ifchildren %}
                &lt;ul&gt;
                    {% children %}
                &lt;/ul&gt;
            {% endifchildren %}
        &lt;/li&gt;
    {% endnav %}
&lt;/ul&gt;
</code></pre>

<p>If the url is accessed directly you can add a redirect to the template.</p>

<pre><code>{% if entry.level == 1 %}
    {% redirect siteUrl %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2014-11-14T16:20:57.770Z
The second snippet of code worked. The url redirect I used `entry.slug` for the redirect. Thank you for the help!
frshjb373
CC BY-SA 3.0
2014-11-14T15:37:35.613Z
2014-11-14T15:42:59.953Z
2014-11-14T15:42:59.953Z
Douglas McDonald
<p>I have an entry that acts as a parent to several children pages. Trying to make so that particular parent isn't clickable AND reroutes to homepage if address url is accessed.</p>

<p>Not sure if I can work something into existing nav code or if this needs to be done somewhere else, but here's the code, nonetheless. Thanks in advance.</p>

<pre><code>&lt;ul&gt;
    {% set pages = craft.entries.section('page') %}
    {% nav page in pages %}
        &lt;li&gt;
            {{ page.getLink() }}
            {% ifchildren %}
                &lt;ul&gt;
                    {% children %}
                &lt;/ul&gt;
            {% endifchildren %}
        &lt;/li&gt;
    {% endnav %}
&lt;/ul&gt;
</code></pre>

CC BY-SA 3.0
2014-11-14T15:26:57.980Z
You can use the redirect tag for this: http://buildwithcraft.com/docs/templating/redirect, something along the lines of {% redirect entry.children.first.uri %}
Jamie Wade
CC BY-SA 3.0
2014-11-14T19:57:43.367Z
Maybe this solution works for you: ["Add home page to a structure?"](http://craftcms.stackexchange.com/q/1467/125)
carlcs
<templating><navigation><redirect><reroute>
Make entry in nav not clickable and reroute
# Make entry in nav not clickable and reroute

(Asked by: username_0 on 2014-11-14)

I have an entry that acts as a parent to several children pages. Trying to make so that particular parent isn't clickable AND reroutes to homepage if address url is accessed.
Not sure if I can work something into existing nav code or if this needs to be done somewhere else, but here's the code, nonetheless. Thanks in advance.

    {% set pages = craft.entries.section('page') %}
    {% nav page in pages %}
        
            {{ page.getLink() }}
            {% ifchildren %}
                
                    {% children %}
                
            {% endifchildren %}
        
    {% endnav %}

**Tags:** templating, navigation, redirect, reroute
> **Comments:**
> **username_1**: You can use the redirect tag for this: http://buildwithcraft.com/docs/templating/redirect, something along the lines of {% redirect entry.children.first.uri %}  
> **username_2**: Maybe this solution works for you: ["Add home page to a structure?"](http://craftcms.stackexchange.com/q/1467/125)  

---

## 1 answers

### Answer by username_3 on 2014-11-14. Score: 3 | Accepted answer

You can use the level method to determine which iteration of the nav you are on and change the behavior:

    {% set pages = craft.entries.section('page') %}
    {% nav page in pages %}
        
            {% if page.level == 1 %}
                {{ page.title }}
            {% else %}
                {{ page.getLink() }}
            {% endif %}
            {% ifchildren %}
                
                    {% children %}
                
            {% endifchildren %}
        
    {% endnav %}


of if it's only one particular entry, then you can create a conditional to check for that entry (using slug, id, title, or any other attribute or field value).

    {% set pages = craft.entries.section('page') %}
    {% nav page in pages %}
        
            {% if page.slug == "myPage" %}
                {{ page.title }}
            {% else %}
                {{ page.getLink() }}
            {% endif %}
            {% ifchildren %}
                
                    {% children %}
                
            {% endifchildren %}
        
    {% endnav %}


If the url is accessed directly you can add a redirect to the template.
{% if entry.level == 1 %}
    {% redirect siteUrl %}
{% endif %}

> **Comments:**
> **username_0**: The second snippet of code worked. The url redirect I used `entry.slug` for the redirect. Thank you for the help!  

---

