Skip to content

Astro Navigation

Astro has no built-in navigation system like Hugo’s [[menus.main]]. In toa://scribe, Astro navigation is managed via a src/data/nav.json file that controls both the top navigation menu and the command palette.

Astro sites typically have two navigation layers that should mirror each other:

LayerWhat it isWhere it appears
Top navigationMain menu linksNavigation bar at top of every page
Command paletteSearchable jump-anywhere$ jump anywhere… overlay (⌘K)

toa://scribe edits both from the same place — the Navigasjon editor in the sidebar.

Create src/data/nav.json in your Astro repo:

{
"nav": [
{ "label": "reviews", "href": "/reviews/", "keys": "reviews scores" },
{ "label": "news", "href": "/news/", "keys": "news posts latest" },
{ "label": "guides", "href": "/guides/", "keys": "guides how-to" },
{ "label": "about", "href": "/about/", "keys": "about contact" }
],
"palette": [
{
"heading": "pages",
"items": [
{ "label": "about", "href": "/about/", "description": "/about/",
"glyph": "", "hint": "page", "keys": "about contact" },
{ "label": "contact", "href": "/contact/", "description": "/contact/",
"glyph": "", "hint": "page", "keys": "contact email" }
]
}
]
}

The nav array controls which links appear in the top navigation bar. Each item has:

FieldRequiredDescription
labelYesLink text shown in nav bar
hrefYesURL the link points to
keysNoSearch keywords for command palette

The palette array controls the command palette sections (⌘K). Each section has a heading and a list of items.

Each palette item has:

FieldRequiredDescription
labelYesDisplay name
hrefYesURL
descriptionNoShown as subtitle
glyphNoIcon character (e.g. , ://)
hintNoRight-side label (e.g. page, live)
keysNoSearch keywords
externalNotrue opens in new tab

In your nav component (e.g. src/components/Nav.astro):

import navData from '../data/nav.json';
// Top navigation
const navItems = navData.nav;
// Command palette sections
const paletteSections = navData.palette;

Then render top nav:

{navItems.map(item => (
<a href={item.href}>{item.label}</a>
))}

Add src/data as a data edit zone in src/data/scribe.yaml:

edit_zones:
- path: src/data
label: Data files
type: data

scribe will then show a Navigasjon button in the sidebar for your Astro repo. Clicking it opens the navigation editor with two sections:

  1. Topmeny — edit top navigation links (order, label, URL)
  2. Palette sections — edit command palette sections and items