Hi,
I'm wondering how easy it is to customize the menu in grav. In particular, I have a page with several section heads/anchors, two of which I would like added to the menu. Any ideas on how to do this?
Thanks!
Community guidelines
Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.
Hi,
I'm wondering how easy it is to customize the menu in grav. In particular, I have a page with several section heads/anchors, two of which I would like added to the menu. Any ideas on how to do this?
Thanks!
Hi @zoof, what theme are you using? One option with some themes is to add custom menu entries to the site.yaml file, here is an example:
https://github.com/hibbitts-design/grav-skeleton-course-hub/blob/master/config/site.yaml#L29-L33
And here is the related Twig at work, with Antimatter:
https://github.com/getgrav/grav-theme-antimatter/blob/develop/templates/partials/navigation.html.twig#L40-L47
This Twig might also be of interest (used to add menu items for Modular page sections):
https://github.com/getgrav/grav-theme-antimatter/blob/develop/templates/modular.html.twig
@paulhibbitts, Many thanks! I'm using Antimatter and I tried your first suggestion and that worked great, adding entries at the end of the list. Is there any way to insert them before the end?
I started by trying Modular page sections but I didn't like the way it looked.
I managed it in a completely hacky way -- I manually added menu entries in site.yaml and deleted the for-loop that looks for menu entries: https://github.com/getgrav/grav-theme-antimatter/blob/develop/templates/partials/navigation.html.twig#L29-L38
Maybe there is a nicer way???
Glad you got something working @zoof ! I myself do not know a better way that that, maybe someone else here might??
Log in to reply.
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 4 | 192 | 2 months ago | ||
| 3 | 89 | 2 months ago | ||
| 11 | 447 | 3 months ago | ||
| 0 | 42 | 3 months ago | ||
| 5 | 122 | 3 months ago |