Customizing Menus
Files: src/config/menu.<lang>.json · Skill level: Beginner
Upstart has one menu file for each language: src/config/menu.en.json, menu.fr.json, and menu.ar.json. Each file has these lists:
headerPrimary: the header menu, with dropdowns and the mega menufooterMenuQuickLink,footerMenuResources, andfooterMenuLegal: the footer columnsfooterMenu: the row at the bottom of the footer
In the Tina edition, you edit these under Menus at /admin/, in the file for your language. In the Sanity edition, the file doesn’t exist: open Content, your language, Menus in the Studio, then Header menu, the Footer column lists, and Footer bottom row.
For how the menu behaves, and for keyboard support, see Navigation.
Main Menu
The headerPrimary array defines the primary navigation menu items. These are the three kinds of item.
A plain link:
{ "enable": true, "name": "Contact", "weight": 5, "url": "/contact/" }A dropdown. Add "hasChildren": true and a children list. Give any child its own "hasChildren": true and children, and it opens to the side:
{ "enable": true, "name": "Pages", "weight": 3, "hasChildren": true, "children": [ { "enable": true, "name": "Features", "weight": 1, "url": "/features/" }, { "enable": true, "name": "Integration", "weight": 5, "hasChildren": true, "children": [ { "enable": true, "name": "All Integrations", "weight": 1, "url": "/integration/" } ] } ]}A mega menu. See below.
Configuration Options
name: The display name of the menu item.weight: The position of the menu item in the menu.url: The URL the menu item links to. Use/pricing/for your own pages, and the language prefix is added for you.enable:trueshows the item. An item withfalse, or with noenableat all, is hidden.hasChildren: Makes the item a dropdown, with its links inchildren.hasMegaMenu: Makes the item a mega menu, with its groups inmenus.badgeDisplays a badge next to the menu itemenableShows or hides the badgelabelThe text inside the badgecolorThe color of the badge -primary,info,success,dangertypeThe type of badge -text,dot
Upstart Sorts The Header Menu Byweight
Upstart sorts the header menu by weight, not by the order in the file. Lower numbers come first. This applies at every level: top-level items, dropdown links, nested links, and mega menu groups and their links. An item with no weight goes last.
To move an item, change its weight, not only its place in the file.
Features Mega Menu
In Upstart theme, the Features item in headerPrimary is a mega menu. Set hasMegaMenu to true, list groups of links in menus, and add the photo card with cta.
{ "enable": true, "name": "Features", "weight": 2, "hasMegaMenu": true, "menus": [ { "enable": true, "name": "Why Upstart", "weight": 1, "children": [ { "enable": true, "name": "Focus on What Matters", "description": "Upstart tracks the essential website metrics you care about.", "icon": "/images/icons/svg/focus.svg", "url": "/features/", "weight": 1 } ] } ], "cta": { "enable": true, "image": "/images/menu-cta.png", "title": "Gain Actionable Insights", "description": "Upstart is self-hosted, meaning your website data stays on your server.", "button": { "enable": true, "label": "Get Free Trial", "url": "/contact/", "rel": "", "target": "" } }}menus: the groups of links. The first group is shown in large type when there are two or more.description: a short line about the link.icon: the path to an image file insrc/assets/images/. In Upstart, the icon shows only in the mobile menu. The large-screen panel shows the links as text.cta: the photo card. It can also haveeyebrowand anitemslist.
You can also add bar, a row along the bottom of the panel, with enable, text, label, and url. It isn’t used in the sample menu. The bar also shows the phone number from [settings.contactInfo] in config.toml.
Footer Menus
The footer menus are defined under footerMenuQuickLink, footerMenuResources, footerMenuLegal, and footerMenu. Each array represents a section in the footer.
Example of Footer Menu:
{ "footerMenu": [ { "enable": true, "name": "Terms & Conditions", "url": "/terms-conditions/", "weight": 0 }, { "enable": true, "name": "Privacy & Policy", "url": "/privacy-policy/", "weight": 0 } ]}Upstart shows every link in these lists, in the order in the file. enable and weight have no effect in the footer, so delete a link to remove it.
The column headings aren’t in this file. They are quickLinks, resources, and legal under footer in src/i18n/<lang>.json. See Footer.
Adding New Menu Items
To add a new menu item:
- Locate the appropriate list in each
menu.<lang>.jsonfile (e.g.,headerPrimaryfor primary navigation). - Add a new object with the required fields (
enable,name,url), and aweightin the header menu. - Save the file, and the new item will appear in the corresponding menu on your site.
Disabling Menu Items
To hide a header menu item, set the enable property to false.
{ "enable": false, "name": "Old Page", "weight": 6, "url": "/old-page/"}This will hide “Old Page” from the navigation.
Do It With AI
Add a link called "[NAME]" to [PLACE IN THE HEADER MENU], pointing to [URL]. Edit headerPrimary inevery src/config/menu.<lang>.json file, and translate the name for each language. Upstart sorts theheader menu by weight, so give the item a weight that puts it in the right place. Keep the sameitem shape as the existing items, with "enable": true. Don't change the navigation components.Then run npm run astro-check.