# Next.js Documentation Conventions
Complete reference for frontmatter schema, code block formatting, and MDX component usage.
## Frontmatter Schema
All MDX files must start with YAML frontmatter enclosed in `---` delimiters.
### Required Fields
| Field | Description | Example |
| ------------- | ------------------------------------------- | ------------------------------------------------ |
| `title` | Page title for SEO and headings (2-3 words) | `title: Image Component` |
| `description` | Brief description (1-2 sentences) | `description: Optimize images using next/image.` |
### Optional Fields
| Field | Description | Example |
| ----------- | -------------------------------------------------- | -------------------------------------------- |
| `nav_title` | Shorter title for navigation sidebar | `nav_title: Image` |
| `source` | Pull content from another page (avoid duplication) | `source: app/api-reference/components/image` |
| `related` | Next steps section with related links | See below |
| `version` | Development stage indicator | `version: experimental` |
### Related Links Format
```yaml
---
title: My Feature
description: Description here.
related:
title: Next Steps
description: Learn more about related features.
links:
- app/api-reference/components/image
- app/guides/optimizing/images
---
```
### Version Field Values
- `experimental` - Experimental feature, may change
- `legacy` - Legacy feature, consider alternatives
- `unstable` - Unstable API, not recommended for production
- `RC` - Release candidate
## Code Block Conventions
### Basic Syntax
````
```language filename="path/to/file.ext"
code here
```
````
### Required Attributes
| Attribute | When to Use | Example |
| ----------- | --------------------------------- | ------------------------- |
| `filename` | Always for code examples | `filename="app/page.tsx"` |
| `switcher` | When providing TS and JS variants | `switcher` |
| `highlight` | To highlight specific lines | `highlight={1,3-5}` |
### TypeScript/JavaScript Switcher Pattern
Always provide TypeScript first, then JavaScript:
````mdx
```tsx filename="app/page.tsx" switcher
import type { Metadata } from 'next'
export const metadata: Metadata = {
title: 'My Page',
}
```
```jsx filename="app/page.js" switcher
export const metadata = {
title: 'My Page',
}
```
````
### Terminal Commands
Use `bash` language without filename:
````mdx
```bash
npm install next
```
````
### Highlighting Lines
```
highlight={1} # Single line
highlight={1,3} # Multiple lines
highlight={1-5} # Range
highlight={1,3-5,8} # Combined
```
## MDX Components
### AppOnly / PagesOnly
Use for router-specific content in shared documentation:
```mdx