- add logos and images
- enforce validation for strings, numbers, and URLs
- nest multiple levels of navigation
Modeling your menu in ButterCMS
Create a single level menu
Follow the below steps to create a simple, flat menu with the following hierarchy:Main menu
Home
About
Features
Try it
Testimonials
Blog
Create the Menu Item Collection
First, build the schema for your menu items. Important fields include:
Save it as “Navigation Menu Item”:
- Label - The display text
- URL - What the item links to
Create the Parent Menu Collection
Create a second Collection for the main menu that references the menu items:
- Name - The navigation menu name
- Menu Items - A Reference field linking to Navigation Menu Item (One-to-Many)
Add Menu Items
Click New item to add items to your Collection:
Add each navigation item with its label and URL:
Building a complex multi-level menu
For complex menus with multiple levels, create separate Collections for each level. Here’s an example hierarchy:Create second-level collection
“Menu - Second Level” includes a Reference field linking to Third Level:
Common navigation patterns
- Header with logo and links
- E-commerce
Collection schema for Header Navigation:
| Field | Type | Purpose |
|---|---|---|
logo | Media | Site logo image |
logo_alt | Short Text | Alt text for logo |
menu_items | Reference | Links to Navigation Menu Items |
cta_button_text | Short Text | Call-to-action text |
cta_button_url | Short Text | CTA destination URL |
Fetching navigation via API
JavaScript/Node.js
Multi-level menu fetch
React component
Performance tips
- Cache navigation responses at the edge or in your app layer (5-10 minutes is typical).
- Use
levelssparingly to avoid oversized responses for deep menus.
Best practices
Content modeling- Separate concerns: Use different Collections for header vs footer
- Include icons: Add optional Media fields for menu item icons
- Support external links: Include a checkbox for “Open in new tab”
- Add ordering: Use a Number field if you need custom sort order
- Use semantic HTML:
<nav>,<ul>,<li>elements - Add ARIA labels:
aria-label,aria-expandedfor dropdowns - Keyboard navigation: Ensure all items are focusable
- Mobile considerations: Include hamburger menu for small screens