---
title: "content.navigation()"
description: "Build a hierarchical navigation tree from the manifest."
canonical_url: "https://content.comark.dev/reference/content/navigation"
---
# content.navigation()

> Build a hierarchical navigation tree from the manifest.

## `content.navigation()`

Builds a hierarchical [`NavigationItem`](https://content.comark.dev/reference/types/content#navigationitem) tree from the manifest, honoring numeric filename prefixes, `.navigation.yml` config files, and each document's `data.navigation`.

**Parameters:** none.

**Returns:** `Promise<`[`NavigationItem[]`](https://content.comark.dev/reference/types/content#navigationitem)`>`

```ts [usage.ts]
const nav = await content.navigation()
```

Files sort by `stem`; a directory with an `index.md` collapses into a single entry. Top-level fields in `.navigation.yml` override a directory's title/icon, while the special top-level `navigation: false` field hides it. A file's frontmatter `navigation.title` shadows its `title` in the sidebar, and its own `navigation: false` keeps it out of the tree entirely.

The directory around an opted-out `index.md` stays as an unlinked group (`page: false`), but it is rebuilt from the siblings: it is titled after the directory name rather than the index page, and a directory holding nothing else disappears along with it. Give the group its own title through a `.navigation.yml`.

## Usage

Register the [`yaml` plugin](https://content.comark.dev/plugins/built-in/yaml) so `.navigation.yml` files are parsed:

```ts [content.ts] {2,7}
import { comarkContent } from 'comark-content'
import yaml from 'comark-content/plugins/yaml'
import fs from 'comark-content/sources/fs'

const content = comarkContent({
  source: fs('./content'),
  plugins: [yaml()],
})

const nav = await content.navigation()
```


## Sitemap

See the full [sitemap](https://content.comark.dev/sitemap.md) for all pages.
