Menu dropdown issue

Hello all,

I’ve been struggling to remove a submenu dropdown arrow under the “home” menu item at:

I’ve set “onpage_menu: false” but am not sure what else might be causing the dropdown.

Any help would be much appreciated. I’m using the photographer theme.


For clarity this is the menu I’m referring to:

This is my frontmatter file:

title: 'Violin Tutor’
menu: Home
onpage_menu: false
dir: asc
by: default
- _slider
- _welcome
- _categories
items: '@self.modular
body_class: index
header_class: alt

If you inspect the partials/navigation.html.twig you can see what is happening.

Well it’s doing that because there must be a child page beneath the ‘home’ page that is not visible. There’s a navigation loop that is checking if there are children, and then if so, it displays the <ul></ul> block, but then as it loops over the children it checks visible(). Clearly nothing visible is found, so there’s an empty <ul></ul> tag left, which displays as an empty dropdown menu.

This is a little tricky to fix with the loop because you need those ul’s outside the for loop, but you don’t know there’s anything in there until you iterate over it.

What ‘folder’ do you have under the home folder? Is it needed? Perhaps you can make the check more specific than just .children() check.

Thanks for the quick advice!

This is my current folder structure for ‘01.home’:

I re-used the theme’s structure, just deleting module blocks which I did not need.

Item ‘03.violin-classes’ is rendering correctly as sub-pages as opposed to modules for item ‘01.home’ which is showing the menu even though the subitems are supposed to be modules.

It is rather tricky for me still (as I really dive into grav’s internals) as I can’t seem to see any extra files but I’m wondering if I can just hardcode to remove the child page if iterating over the ‘home’ page?

Ok try changing this line to :

{% if p.children.nonModular.count > 0 %}

Brilliant! All fixed now at :slight_smile:

Thanks again for the kind assistance.


Cool, glad you got it sorted