How give parent in navigation-structure the active tag So I have a two-level Navigation in a structure. What I want is to give the parent of my entry (if a parent exists) the active tag.

right now I'm doing that:

{% for nav_item in navigation %}
  &lt;li class="{% if craft.request.getSegment(1) == nav_item.nav_url %}active {% endif %}{% if nav_item.hasDescendants() %}more{% endif %}"&gt;

    &lt;a href="{{nav_item.nav_url}}"&gt;{{nav_item.title}}&lt;/a&gt;

  {% if nav_item.hasDescendants() %}
    &lt;ul class="submenu"&gt;
      {% for child in nav_item.getChildren() %}
        &lt;li&gt;
            &lt;a href="{{child.nav_url}}"&gt;{{child.title}}&lt;/a&gt;
        &lt;/li&gt;
      {% endfor %}
    &lt;/ul&gt;
  {% endif %}
  &lt;/li&gt;
{% endfor %}


sadly most children don't share the first segment
How a look at the isAncestorOf() method in the Docs. The given example code probably covers all you need:

{% set expanded = entry is defined and page.isAncestorOf(entry) %}
&lt;li{% if expanded %} class="expanded"{% endif %}&gt;


To only address the direct parent, use isParentOf() instead.