How to get first child URL within Craft/Twig Nav tags I have a navigation structure as follows:

{% set page = entry ?? category ?? null %}

&lt;ul class="nav menu--main"&gt;
    {% nav entry in entries %}

        &lt;li class="menu__item{% if page and page.id == entry.id %} is-current{% endif %}"&gt;

            &lt;a {% if entry.type == 'noLink' %}href=""{% else %}href="{{ entry.url }}"{% endif %}&gt;{{ entry.title }}&lt;/a&gt;

            {% ifchildren %}
                &lt;ul class="nav menu--submenu__wrapper"&gt;
                    {% children %}
                &lt;/ul&gt;
            {% endifchildren %}

        &lt;/li&gt;

    {% endnav %}
&lt;/ul&gt;


As you can see, I have an entry.type called "No link" which means that the user doesn't want the parent page to have a page of it's own, yet it still needs to appear in the nav to give context to the children.

My question is; how can I get the first child's URL within the ifchildren tags so I can make the parent automatically redirect to the first child's page in the navigation?

I know how to do this in regular forloops, but it would be nice to do this within Craft's nav tags.

Thanks,
Jay
In that case you can put this in the href value:

{{ entry.descendants.type('page').first.url ?? '' }}


(Replace page with the other entry type handle(s).)