Support the ongoing development of Laravel.io →
Views Blade Architecture

Hi, howcan you create a menu in laravel?

Because It would be bad if I copy&pasted the menu on every page.

My idea was to make the menu in a seperate file that I include in my master Layout. This way I have the menu just once. Thus, I can edit it easier.

But this way I can't highlight the current page in the menu (e.g. a class="active" at the menu point that is active).

Do you have any ideas? Thank you :)

Last updated 2 years ago.
0

Well you should be able to highlight it, you could do something like this in your partial

<li class="{{( Request::segment('1') == 'something' ? 'active' : false )}}"><a href="{{ url('something')}}">Something</a></li>

Or you could write your own class where you can check if it's active and whatnot, but for simple menus I believe it's ok to do just like my example

Last updated 2 years ago.
0

Thank you :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

d3mueller d3mueller Joined 29 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.