# Customizing Menus

## **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 menu
- `footerMenuQuickLink`, `footerMenuResources`, and `footerMenuLegal`: the footer columns
- `footerMenu`: 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](../../features/navigation/).

<Aside type="caution">
  Change the menu file of **every language** when you add or remove a link, so
  the menus stay in step.
</Aside>

### **Main Menu**

The `headerPrimary` array defines the primary navigation menu items. These are the three kinds of item.

**A plain link:**

```json
{ "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:

```json
{
  "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`: `true` shows the item. An item with `false`, or with no `enable` at all, is hidden.
- `hasChildren`: Makes the item a dropdown, with its links in `children`.
- `hasMegaMenu`: Makes the item a mega menu, with its groups in `menus`.
- `badge` Displays a badge next to the menu item
  - `enable` Shows or hides the badge
  - `label` The text inside the badge
  - `color` The color of the badge - `primary`, `info`, `success`, `danger`
  - `type` The type of badge - `text`, `dot`

### Upstart Sorts The Header Menu By `weight`
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`.

```json
{
  "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 in `src/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 have `eyebrow` and an `items` list.

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:**

```json
{
  "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](../footer/).

### **Adding New Menu Items**

To add a new menu item:

1. Locate the appropriate list in each `menu.<lang>.json` file (e.g., `headerPrimary` for primary navigation).
2. Add a new object with the required fields (`enable`, `name`, `url`), and a `weight` in the header menu.
3. 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`.

```json
{
  "enable": false,
  "name": "Old Page",
  "weight": 6,
  "url": "/old-page/"
}
```

This will hide "Old Page" from the navigation.

### Do It With AI
```text
Add a link called "[NAME]" to [PLACE IN THE HEADER MENU], pointing to [URL]. Edit headerPrimary in
every src/config/menu.<lang>.json file, and translate the name for each language. Upstart sorts the
header menu by weight, so give the item a weight that puts it in the right place. Keep the same
item shape as the existing items, with "enable": true. Don't change the navigation components.
Then run npm run astro-check.
```