The Collection Menu include file generates a dropdown navigation menu for a Jekyll collection, grouping items by their category
field. It is particularly useful for displaying structured documentation, guides, or other content collections.
To use this include in your Jekyll theme, add the following line to your template:
{% include collection-menu.html collection=site.docs name="Documentation" index=site.docs_index id="docs-menu" %}
Parameter | Default | Description |
---|---|---|
collection |
site.docs |
The Jekyll collection to display in the menu. |
name |
None | Display name for the collection in the menu header. |
index |
None | Index page object for the collection, used as the main link in the menu header. |
id |
collection-menu |
HTML id attribute for the <details> element; useful for multiple instances. |
{% include collection-menu.html collection=site.tutorials name="Tutorials" index=site.tutorials_index id="tutorials-menu" %}
details-overlay
pattern to create a dropdown.category
front matter field.aria-current="page"
when its URL matches the menu item.index
is provided, the collection name in the header becomes a link to the index page.This include relies on:
details-overlay
, SelectMenu
, SideNav
are part of Primer’s styling system.SideNav
, SelectMenu
, or AppHeader-link
.category
field in their front matter for grouping.id
parameter allows multiple instances of this menu to coexist on a page without conflicts.aria-haspopup
and aria-current
attributes enhance accessibility for the dropdown menu and navigation links.By integrating collection-menu.html
, you can create a well-structured and accessible collection menu that enhances site navigation.