# Menus

## Menus

**Files:** `src/config/menu.<language>.json` · **Skill level:** Beginner

The header menu and the footer link columns live in one JSON file per language: `menu.en.json`, `menu.fr.json`, and `menu.ar.json`. Keep the files in the same shape: same items, same order, same URLs. Only the `name` and `label` texts differ.

Each file has two lists:

```json
{
  "headerPrimary": [ ... ],
  "footer": [ ... ]
}
```

For how the menu behaves on screen and with the keyboard, see [Navigation](/givo/features/navigation/).

### Header Menu
Each item in `headerPrimary` is one entry in the top menu. There are three kinds of item.

**A plain link.** **Stories** is one:

```json
{ "enable": true, "name": "Stories", "weight": 4, "url": "/blog/" }
```

**A dropdown.** Set `"hasChildren": true` and list the links in `children`. This is the **Get involved** menu, trimmed:

```json
{
  "enable": true,
  "name": "Get involved",
  "weight": 2,
  "hasChildren": true,
  "children": [
    { "enable": true, "name": "Volunteer", "url": "/volunteer/", "weight": 1 },
    { "enable": true, "name": "Fundraise", "url": "/fundraise/", "weight": 2 },
    { "enable": true, "name": "Events", "url": "/events/", "weight": 3 }
  ]
}
```

**A mega menu.** Set `"hasMegaMenu": true` and list groups of links in `menus`. The **Causes** menu is one: see [The Causes Mega Menu](#the-causes-mega-menu) below.

| Key           | What it does                                                                                     |
| ------------- | ------------------------------------------------------------------------------------------------ |
| `enable`      | `false` hides the item without deleting it                                                       |
| `name`        | The text in the menu                                                                             |
| `weight`      | A position number. The menu shows items in the order of the file, so move an item in the file to move it in the menu |
| `url`         | Where it links. Write paths without the language: `/causes/`, not `/fr/causes/`. The other languages add their prefix themselves. An item with children has no `url` |
| `hasChildren` | `true` makes the item a dropdown                                                                 |
| `children`    | The links inside the dropdown. A child with its own `hasChildren` and `children` opens a flyout  |
| `hasMegaMenu` | `true` makes the item a mega menu                                                                |
| `menus`       | The columns of a mega menu, each with `enable`, `name`, `weight`, and `children`. The `name` is a small heading, not a link |
| `cta`         | The card beside the columns of a mega menu                                                       |
| `bar`         | The row along the bottom of a mega menu, with `enable`, `text`, `label`, and `url`               |

### The Causes Mega Menu
<div class="border border-dark">
  ![The Causes mega menu, with the featured cause card](/images/givo/mega-menu.jpg)
</div>

**Causes** has one column per cause category, a card for one featured cause, and an **All causes** row. Trimmed:

```json
{
  "enable": true,
  "name": "Causes",
  "weight": 1,
  "hasMegaMenu": true,
  "menus": [
    {
      "enable": true,
      "name": "Education",
      "weight": 1,
      "children": [
        { "enable": true, "name": "School supplies for every child", "description": "", "icon": "", "url": "/causes/school-supplies-for-every-child/", "weight": 1 },
        { "enable": true, "name": "After-school reading club", "description": "", "icon": "", "url": "/causes/after-school-reading-club/", "weight": 2 }
      ]
    }
  ],
  "cta": {
    "enable": true,
    "eyebrow": "Featured cause",
    "cause": "school-supplies-for-every-child",
    "image": "",
    "title": "",
    "description": "",
    "items": [],
    "button": { "enable": true, "label": "Donate now", "url": "/donate/?cause=school-supplies-for-every-child" }
  },
  "bar": { "enable": true, "text": "", "label": "All causes", "url": "/causes/" }
}
```

- **The columns** are plain links. The column names match the cause categories, but the menu doesn't read them: you write each link yourself.
- **`cta.cause`** is the id of a cause: its file name in `src/content/causes/<language>/` without `.md`. The card then shows that cause's title (linked to its page), a thin progress line, and "$… raised of $…", read from the cause file when the site is built. `title` replaces the cause's title; `eyebrow`, `description`, a short `items` checklist, and an `image` are optional. Without `cause`, the card shows only what you write.
- **`cta.button`** is the button at the bottom of the card. Point it at `/donate/?cause=<id>` so the donation form opens with that cause chosen. `"enable": false` on `cta` hides the whole card.
- **`bar`** is the row along the bottom: an optional line of `text`, and a link (`label`, `url`).

To feature another cause, change `cause` and the cause id in the button's `url`, in every language file.

<Aside type="caution" title="New causes don't appear on their own">
  The header menu is plain data. When you add a cause, add its link to the
  right column of the **Causes** menu in every language, and to the **Cause
  detail** flyout of the **Pages** menu if you keep it. See [Causes &
  Campaigns](/givo/customization/causes-campaigns/).
</Aside>

### Flyouts
A child that has its own `hasChildren` and `children` opens a flyout to the side, and it flips if there is no room. The **Pages** menu uses this to list every page of the theme:

```json
{
  "enable": true,
  "name": "Pages",
  "weight": 5,
  "hasChildren": true,
  "children": [
    {
      "enable": true,
      "name": "Homepages",
      "weight": 1,
      "hasChildren": true,
      "children": [
        { "enable": true, "name": "Main homepage", "url": "/", "weight": 1 },
        { "enable": true, "name": "Urgent appeal", "url": "/home-appeal/", "weight": 2 },
        { "enable": true, "name": "Community charity", "url": "/home-community/", "weight": 3 }
      ]
    }
  ]
}
```

You can nest as deep as you like. On phones, the same levels open as lists inside the mobile menu.

<Aside type="tip" title="Hide the Pages menu on your site">
  **Pages** is a catalog of the demo: it links to the three homepages, the
  sample detail pages, and `/elements/`. Set its `"enable"` to `false` in every
  menu file before you launch. Its useful links are already in **Get
  involved** and **About**, except **Gallery**: add that to **About** if you
  keep the gallery page.
</Aside>

### Footer Menus
`footer` is a list of link columns. Each has a `label` (the column heading) and a `list` of links:

```json
"footer": [
  {
    "label": "Give",
    "list": [
      { "enable": true, "name": "Donate", "url": "/donate/" },
      { "enable": true, "name": "Monthly giving", "url": "/donate/#monthly" }
    ]
  },
  {
    "label": "Legal",
    "list": [
      { "enable": true, "name": "Terms", "url": "/terms-conditions/" },
      { "enable": true, "name": "Privacy policy", "url": "/privacy-policy/" },
      { "enable": true, "name": "Cookie settings", "url": "#cookie-settings" }
    ]
  }
]
```

The shipped file has four columns: **Give**, **Get involved**, **About**, and **Legal**.

- **The last column holds the legal links.** Every footer layout shows it in its bottom row, next to the copyright, instead of as a column. Keep Legal last.
- The `default` and `large` footers show every other column. The `minimal` footer shows the first two. See [Footer](/givo/customization/footer/).

The **Cookie settings** link (`#cookie-settings`) reopens the cookie banner. If you turn the banner off in `[settings.cookieConsent]`, set this item's `enable` to `false`.

### Keep Every Language In Step
`npm run check-i18n` (also part of `npm run astro-check`) compares each language's menu file with `menu.en.json` and reports a difference in the number of items or a `url`. So when you add, remove, or move a menu item, do it in every file.

JSON is strict: every item but the last in a list needs a comma after it, and every name and URL needs double quotes. A missing comma stops the site from building. See [File Formats](/givo/beginner/file-formats/).

### Do It With AI
```text
In each src/config/menu.<language>.json: set "enable": false on the "Pages" item in
headerPrimary, and add a "Gallery" link to /gallery/, translated, at the end of the About
dropdown. In the Causes mega menu, add a link to /causes/[CAUSE ID]/ named "[TITLE]" (translated)
to the [CATEGORY] column, and set cta.cause and the cta button's ?cause= to "[CAUSE ID]". Keep
every file in the same structure and the Legal footer column last, then run npm run check-i18n.
```