---
title: Nested entries
description: Put entries inside other entries, like the pages of a help center, with paths of several levels, a tree for the sidebar and breadcrumbs.
section: guides
order: 18
---

# Nested entries

A help center, a handbook or a manual has pages inside pages. A nested collection lets an entry have a parent of the same collection and locale, as deep as the collection allows. Its path holds the slugs of its ancestors, `/help/billing/payments/refunds/`, and a site reads the collection as a tree.

## Turn it on

A collection's `nesting` says how many levels it allows, from 2 to 10:

```json
"nesting": { "maxDepth": 3 }
```

In the admin, under **Settings → Collections**, turn on **Nested entries** and choose its levels. Over MCP, send the collection with `set_collection`. Without `nesting`, entries are flat, as before.

The route of the collection does not change: `/help/:slug/` gives `/help/billing/` to a root and `/help/billing/payments/refunds/` to an entry three levels down. Hollware refuses a depth below the deepest entry there is: move those entries up first.

## Write the tree

An agent creates an entry under another with `parent`, the slug of the parent:

```json
{ "collection": "help", "locale": "en", "slug": "refunds", "parent": "payments", "markdown": "---\ntitle: Refunds\n---\n\n…" }
```

It goes last among its siblings. `move_entry` moves an entry, with every entry below it:

| Input    | What it does                                                                   |
| -------- | ------------------------------------------------------------------------------ |
| `parent` | the slug of its new parent, or `null` for the root                             |
| `index`  | its place among the children of its parent, from 0; past the end, it goes last |
| `slug`   | a new slug                                                                     |

A move that would put an entry inside itself or one of its children, or deeper than the collection allows, answers `invalid_parent`, with the reason. In the admin, the entries of a nested collection show as a tree in a locale: drag an entry onto another to put it inside, above or below, or use its menu to move it up, down, into the entry above or out to its parent. **New entry inside** starts a child.

Slugs stay unique in a collection and locale, whatever their parent: two pages called "Introduction" in two branches need two slugs, such as `introduction` and `billing-introduction`.

## Publish the tree

An entry is published only when its ancestors are: publishing a child of a draft is blocked, with the parent to publish first. Publish both in one group, with `group`, and they go out together. The other way round, a parent with published children is not unpublished, trashed or deleted for ever until its children are: the answer, `has_children`, lists them. A review that unpublishes a parent includes its published children, and an entry whose parent is in the trash comes back from it after its parent.

Every write that changes the tree keeps it whole, even when two people move entries at once: a write that would break it writes nothing and runs again with what is there now.

## Moving keeps the old paths

A move changes the path of the entry and of every entry below it. Each entry that was ever published keeps its old path as a redirect, and a site that asks for an old path learns where the entry is now. A link of a body to an old path is reported by `internal-links-resolve`, with the path the entry has now.

## Read it from a site

A nested collection needs one route on the site for any depth, such as `/help/*`, and `getPage` to turn the path into the entry:

```ts
const page = await hollware.getPage(new URL(request.url).pathname, { request })
if (page.outcome === 'redirect') return Response.redirect(new URL(page.path, request.url), 301)
if (page.outcome === 'not_found') return new Response('Not found', { status: 404 })
// page.entry, and page.ancestors for breadcrumbs: [{ slug, title, path }]
```

`getPage` is `resolvePath` and then `getEntry`. `resolvePath` answers `ok` with the collection, locale and slug of the entry, `redirect` with the path it has now for an older one, or `not_found`. It is a method of the service binding and of `@hollware/client`, and `GET /v1/resolve?path=/help/billing/` over HTTP.

The navigation of a nested collection is a tree: each entry has its `parent` and its `children`, in the order you gave them. `trailOf(navigation, slug)` gives the entries from the root down to one, for breadcrumbs, and `flattenNavigation(navigation)` every entry in the order of the sidebar, for previous and next. See [Navigation for a sidebar](/docs/navigation/#a-nested-collection).

| Framework             | Route                  | Read it                                                                                               |
| --------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------- |
| React Router, Next.js | `help/*`               | `createHollware(…).getPage(pathname, { request })`, with `<HollwareTree>` and `<HollwareBreadcrumbs>` |
| Nuxt                  | `help/[...path].vue`   | `useHollwarePage(route.path)`, then `navigateTo(path, { redirectCode: 301 })` on a redirect           |
| Vue                   | any                    | `useHollwarePage(path)`                                                                               |
| Astro                 | `help/[...path].astro` | `getLiveEntry('help', { id: Astro.params.path })`: the id of an entry is its path of slugs            |

The guides of [React](/docs/react/), [Nuxt](/docs/nuxt/), [Vue](/docs/vue/) and [Astro](/docs/astro/) show each one whole.

## Bring a tree in

`hollware import --from notion` keeps the tree of Notion in a nested collection: each page goes under its parent, in the order of Notion ([Import from Notion](/docs/import-from-notion/#into-a-nested-collection)). From Markdown, a folder is a parent: `help/en/billing/refunds.md` goes under `help/en/billing.md`. `hollware export` writes a nested collection in folders, with the order of the siblings in `_order.json`, so an export imports back as the same tree.
