如何向 Bolt CMS 添加二级菜单?

How to add a secondary menu to Bolt CMS?

将菜单添加到模板的默认方式::

{{ menu(identifier = 'footer',
        template = 'partials/_sub_menu.twig',
        params = {'withsubmenus': false, 'class': 'inline-list align-right'}**strong text**
) }}

但是如何从 menu.yml 之外的其他文件构建二级菜单?

要添加二级菜单,请转至 menu.yml 为上述示例添加以下代码行:

footer:
    - label: Imprint
      title: Go to Imprint
      path: page/imprint
      class: first

可以在此处找到文档:https://docs.bolt.cm/3.0/content/menus

Further explanation:

  1. 所有使用的菜单都必须在menu.yml中声明。

  2. 要正确呈现它们,您可以用两种不同的方式调用它们。

示例 #1:

{{ menu(identifier = 'footer', template = 'partials/_sub_menu.twig') }}

示例 #2(速记语法):

{{ menu(footer', 'partials/_sub_menu.twig') }}

Note: You can define more than one menu in your menu.yml file, but you should define only one menu in each template file. So, if you have multiple menus that should be rendered with different HTML, you should have as many _menu_menuname.twig files in your theme.