<p>I am doing something similar in using a Structure for the main navigation.  Below is what I have.  Hope it helps!</p>
<pre><code>{% set menu = craft.entries.section('navMain').all() %}
&lt;ul&gt; 
{% nav link in menu %}
    &lt;li&gt;
    {% if link.menuEntry|length %}
        {% if craft.app.request.absoluteUrl ==  link.menuEntry[0].url %}
        &lt;a href=&quot;{{ link.menuEntry[0].url }}&quot; class=&quot;active&quot;&gt;{{ link.title }}&lt;/a&gt;
        {% else %}
            &lt;a href=&quot;{{ link.menuEntry[0].url }}&quot;&gt;{{ link.title }}&lt;/a&gt;
         {% endif %}
    {% else %}
        {% if craft.app.request.absoluteUrl ==  link.menuCustomURL %}
            &lt;a href=&quot;{{ link.menuCustomURL }}&quot; class=&quot;active&quot;&gt;{{ link.title }}&lt;/a&gt;
        {% else %}
            &lt;a href=&quot;{{ link.menuCustomURL }}&quot;&gt;{{ link.title }}&lt;/a&gt;
        {% endif %}
    {% endif %}
    {% ifchildren %}
        &lt;ul&gt;
            {% children %}
        &lt;/ul&gt;
    {% endifchildren %}
    &lt;/li&gt; 
{% endnav %}
&lt;/ul&gt;
</code></pre>

CC BY-SA 4.0
2021-01-29T19:12:55.930Z
Nevermind, I had somehow removed the parent item. This DOES output the children correctly. Thanks! ---Thanks, this gets the links to output correctly (which I appreciate), but it doesn't structure the children properly (no sub UL for the children).---
doctorgloom
CC BY-SA 4.0
2021-01-28T23:26:13.460Z
2021-01-28T23:26:13.460Z
Todd
<p>I'd like to build a Structure that can be used to output the main site navigation; each &quot;entry&quot; in the Structure would have three custom fields (types): Category, Entries, URL</p>
<p><a href="https://craftcms.stackexchange.com/questions/14019/navigation-structure-and-uri-problems">This question is close to what I want</a>, except it's not using Nav; I want children, so I think I need Nav? Plus I couldn't get that code to work anyway.</p>
<p>Based on <a href="https://craftcms.stackexchange.com/questions/9942/navigation-structure-usage-woes">other questions</a> and the docs, I have this:</p>
<pre><code>{% set pages = craft.entries.section('navDropDownMenu').all() %}
&lt;ul&gt;
    {% nav page in pages %}
        &lt;li&gt;
            {% if page.entriesFieldLink %}
                &lt;a href=&quot;{{ page.entriesFieldLink.first().url|default }}&quot;&gt;{{ page.title }}&lt;/a&gt;
            {% elseif page.urlFieldLink %}
                &lt;a href=&quot;{{{{ page.urlFieldLink.first().url|default }}&quot;&gt;{{ page.title }}&lt;/a&gt;
            {% else %}
                &lt;a href=&quot;{{ page.category.url }}&quot;&gt;{{ page.title }}&lt;/a&gt;
         {% endif %}
            {% ifchildren %}
                &lt;ul&gt;
                    {% children %}
                &lt;/ul&gt;
            {% endifchildren %}
        &lt;/li&gt;
    {% endnav %}
&lt;/ul&gt;
</code></pre>
<p>The only thing that works here is the Category link, except it should be a child but it isn't. I'm new to Craft so I'm probably doing something basic wrong, but any help is appreciated.</p>

<structure><navigation><custom-fieldtype><custom-field>
Structure Navigation with 3 possible Link Types using Nav tag
# Structure Navigation with 3 possible Link Types using Nav tag

(Asked by: username_0 on 2021-01-28)

I'd like to build a Structure that can be used to output the main site navigation; each "entry" in the Structure would have three custom fields (types): Category, Entries, URL
This question is close to what I want, except it's not using Nav; I want children, so I think I need Nav? Plus I couldn't get that code to work anyway.
Based on other questions and the docs, I have this:
{% set pages = craft.entries.section('navDropDownMenu').all() %}

    {% nav page in pages %}
        
            {% if page.entriesFieldLink %}
                {{ page.title }}
            {% elseif page.urlFieldLink %}
                {{ page.title }}
            {% else %}
                {{ page.title }}
         {% endif %}
            {% ifchildren %}
                
                    {% children %}
                
            {% endifchildren %}
        
    {% endnav %}


The only thing that works here is the Category link, except it should be a child but it isn't. I'm new to Craft so I'm probably doing something basic wrong, but any help is appreciated.

**Tags:** structure, navigation, custom-fieldtype, custom-field


---

## 1 answers

### Answer by username_1 on 2021-01-28. Score: 2 | Accepted answer

I am doing something similar in using a Structure for the main navigation.  Below is what I have.  Hope it helps!
{% set menu = craft.entries.section('navMain').all() %}
 
{% nav link in menu %}
    
    {% if link.menuEntry|length %}
        {% if craft.app.request.absoluteUrl ==  link.menuEntry[0].url %}
        {{ link.title }}
        {% else %}
            {{ link.title }}
         {% endif %}
    {% else %}
        {% if craft.app.request.absoluteUrl ==  link.menuCustomURL %}
            {{ link.title }}
        {% else %}
            {{ link.title }}
        {% endif %}
    {% endif %}
    {% ifchildren %}
        
            {% children %}
        
    {% endifchildren %}
     
{% endnav %}

> **Comments:**
> **username_0**: Nevermind, I had somehow removed the parent item. This DOES output the children correctly. Thanks! ---Thanks, this gets the links to output correctly (which I appreciate), but it doesn't structure the children properly (no sub UL for the children).---  

---

