Menu with highlight current page and parent title

Its working :slight_smile:

<h3>{{ page.parent.title }}</h3>

<ul>
	
	{% for p in page.parent.children %}
	
		{% if p == page %}
			<li class="active"><a href="{{p.url}}">{{ p.title }}</a></li>
		{% else %}
			<li><a href="{{p.url}}">{{ p.title }}</a></li>
		{% endif %}
	
	{% endfor %}

</ul>

Oeps… its is also showing invisible and disabled pages.
How can I solve that issue?

Hi @ocean12, you can add some checks to your loop. The page class has many methods to fine-grain your result. To only show visible and maybe published pages change your for loop to

—twig
{% for p in page.parent.children if p.routable and p.visible %}

{% endfor %}


Here `routable` accounts that the page must have a route and `visible` that it must appear in the menu. You can drop the latter, if you don't need it.

Sommerregen