Menu Manager for Kirby

I am currently building my first Kirby theme. So far so good.

But what really bother me, is the fact that there is no good menu system implemented (or I didn’t found it yet). Let me explain.

I want to code something like this:

 <?php echo menu('primary'); ?>

and on my footer something like

 <?php echo menu('footer'); ?>

I don’t know what pages are going to be implemented. Perhaps they change. Perhaps my staff is doing crazy shit.

So it would be great to have a menu manger like Wordpress where I can simply build my menus. Storing that in a yaml-file shouldn’t be the problem and the CLI guys out there could simply edit it in an editor.

And beginners would be much happier I believe.

What do you think / have in mind / tipps do you have for me?

The starterkit does it using visible and invisible pages for example. Another way would be to introduce a checkbox field for top-level templates that can be checked if the page should appear in the menu. These are the two most common ways.

You could also create pages that work as menu builders, i.e. a page with a structure field to enter a menu title and select a page. That way, you can also sort menu items any way you want manually.


That is quite an interesting idea. I will try that one. Thanks a lot.

But if someone wants to make a plugin I would be very very happy :slight_smile:

I had the same problem about a week ago. I wanted a menu system not driven by invisible/visible pages.

Therefor I created the snippetfield which is a modified version of the structure field.

The benefit of using it is that it’s possible to have logic and for example thumbnails of the menu images (if you have menu images).

If you can setup the structure field you can probably setup this plugin.

I’d go the same way @jenstornell suggested and either using his snippet field or the structure field. In addition, I would not create a separate page for this, but store the information in the site.txt – less pages for the panel user, and somehow better organized (it’s clearly a setting, not a page a visitor can go to).

You can even combine this with visible/invisible pages, and using invisible ones just as drafts.


If you only have one menu I think @jakobploens suggestion might be the best, put it in site.

In my case I had a top menu as well as child menus and in that case I used Subpage builder to automatically add a subpage called menu on parent template blueprints.

Then I use a route so the menu “pages” is not indexed but only used as placeholder in the panel.

There are very many ways to setup a menu system. It probably depends on the site and the users, how to work with it.

I agree with @jenstornell, if you only have one or two menus, like a main menu and a footer menu, putting it into /site makes perfect sense.

But it all depends on how many menus you have, if you have a main menu and submenus etc.

Yeah, that’s right. But submenus and stuff could then just be build with a simple checkbox… but yes, it depends on the overall site structure and complexity.

You mean that it work much like the visible pages? I used visible pages at first and then added a menu icon, menu title and a menu subtitle for it, fields on every subpage.

I personally did not like that approach because:

  • When adding stuff for the menu inside the child page I need to look at the front or on every child page to get a good overview of the final menu. Much back and forth.
  • I needed to go to Pages to sort them and make them visible. From time to time I forgot where to order them. If I can’t understand it, my client probably can’t do it eather.
  • It also did not look like the final menu. With my Snippetfield plugin the result looks almost like the final thing.

The big pitfall of my solution, except there is a menu page placeholder is:

  • When I delete a page, it is not reflected in the menu. I need to keep it updated manually. That could be solved with a hook, if needed.

So, I’ve tested both and for my current site I like the subpage version best. For another site, maybe I think different.

Could you write code that checks if pages in your menu still exist, and if not delete the menu entry? Then add a hook on to trigger it.

1 Like

Yes, someting like that. My concern about deleting the menu entry is that if something goes wrong and it can’t find a page the menu item is deleted.

Hide it, don’t delete it

I think it would be more safe if adding a content value like:

visible: false

to the menu item. That way it still exists but is not active, not visible in the frontend.

If Kirby would have trash

If Kirby would have a trash function, it would have been great to use that and put the menu item in trash for 30 days before deletion.

thanks a lot for your replies.

I am not really satisfied with any of these suggestions but I have to make do.

See you in my next “help!” thread :slight_smile: