Pages in multiple categories -> active menu item


My menu looks like this: home, projects, blog, about …

if i create a new page under projects it should also appear in blog.
This already works using collections in my blog

        - self@.children
        - taxonomy@:
                category: project

i use Route Overrides - Route Aliases
so e.g. in “/projects/example_project/” i have “blog/example_project” as Route Alias,
so both urls





now finally to my question:
Depending on which url i use (or how i reached the page) i want ether menu item"projects" or “blog” to be active…

i thied modifiing navigation.html.twig, but i guess thats not the right way(?)
i serched the forums but couldn’t find the answer

Thanks in advance!

I think modifying navigation.html.twig is the right way. However such modification cause difficulty when the theme is updated and without caution you loose your modifications.

A solution is to use theme inheritance. In 2014 rhukster has written a blog post about theme inheritance.

I hope this helps.

Thanks for your answer!
I’m already using theme inheritance, forgot to mention.

problem solved for me:
in ‘navigation.html.twig’ i replaced

{% set active_page = ( or p.activeChild) ? ‘active’ : ‘’ %}


{% set active_page = p.slug == (grav.uri.route|split(’/’)[1]) ? ‘active’ : ‘’ %}

it took a while until i found ‘grav.uri.route’ but now it works perfectly!