Routing
Routing here is file-based. There are two layers working together:
- AnalogJS page components under
docs/src/app/pagesdefine the app's routes. - A single catch-all page renders any Markdown file under
docs/src/content/docs.
The catch-all page
The file pages/docs/[...slug].page.ts matches every URL beneath /docs. The
slug param captures the full remaining path — including slashes — so nested
folders just work:
import { Component } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { injectContent, MarkdownComponent } from '@analogjs/content';
@Component({
selector: 'docs-page',
imports: [MarkdownComponent],
template: `<analog-markdown [content]="doc()?.content" />`,
})
export default class DocPage {
// /docs/guides/routing -> src/content/docs/guides/routing.md
readonly doc = toSignal(
injectContent({ param: 'slug', subdirectory: 'docs' }),
);
}
URL mapping
The path under content/docs becomes the path under /docs:
| File | URL |
|---|---|
content/docs/getting-started.md |
/docs/getting-started |
content/docs/guides/routing.md |
/docs/guides/routing |
content/docs/api/overview.md |
/docs/api/overview |
Frontmatter drives everything
Every file starts with YAML frontmatter:
---
title: Routing
description: Short summary used in lists and meta tags
order: 3
section: Guides
---
titleanddescriptionset the page<title>and meta description.sectiongroups the page in the sidebar.ordersorts pages within a section (and drives previous/next links).
Because the sidebar is generated from this frontmatter, adding a page never requires touching TypeScript. See Auto-generated navigation.
Linking between docs
Use normal Markdown links with absolute paths, like
[Deployment](/docs/guides/deployment). The router intercepts them so navigation
stays a single-page transition.