diff --git a/material/partials/nav-item.html b/material/partials/nav-item.html
index 650bb4db6..427285ad0 100644
--- a/material/partials/nav-item.html
+++ b/material/partials/nav-item.html
@@ -21,9 +21,9 @@
{% endif %}
{% set indexes = [] %}
{% if "navigation.indexes" in features %}
- {% for item in nav_item.children %}
- {% if item.is_index and not index is defined %}
- {% set _ = indexes.append(item) %}
+ {% for nav_item in nav_item.children %}
+ {% if nav_item.is_index and not index is defined %}
+ {% set _ = indexes.append(nav_item) %}
{% endif %}
{% endfor %}
{% endif %}
@@ -51,8 +51,7 @@
{% for nav_item in nav_item.children %}
- {% if "navigation.indexes" in features and nav_item.is_index %}
- {% else %}
+ {% if not indexes or nav_item != indexes | first %}
{{ render(nav_item, path ~ "_" ~ loop.index, level + 1) }}
{% endif %}
{% endfor %}
diff --git a/src/partials/nav-item.html b/src/partials/nav-item.html
index 6f94f9f5a..38a77cb23 100644
--- a/src/partials/nav-item.html
+++ b/src/partials/nav-item.html
@@ -66,9 +66,9 @@
{% set indexes = [] %}
{% if "navigation.indexes" in features %}
- {% for item in nav_item.children %}
- {% if item.is_index and not index is defined %}
- {% set _ = indexes.append(item) %}
+ {% for nav_item in nav_item.children %}
+ {% if nav_item.is_index and not index is defined %}
+ {% set _ = indexes.append(nav_item) %}
{% endif %}
{% endfor %}
{% endif %}
@@ -110,9 +110,7 @@
{% for nav_item in nav_item.children %}
- {% if "navigation.indexes" in features and nav_item.is_index %}
-
- {% else %}
+ {% if not indexes or nav_item != indexes | first %}
{{ render(nav_item, path ~ "_" ~ loop.index, level + 1) }}
{% endif %}
{% endfor %}