>` | The map from `import.meta.glob`. Keys are file paths; each value is a lazy importer whose `default` export is the page component. |
| `options.wrapper` | `ComponentType<{ children }>` | Single-root wrapper around each page. Defaults to a bare ``. |
| `options.slug` | `(key: string) => string` | Map a glob key to its route `path`, overriding the default rule. |
| `options.base` | `string` | Prefix stripped from each key before slug derivation. Defaults to the longest common directory of all keys. |
The default slug rule strips the common directory prefix and the file extension and collapses a trailing `index` to the empty path: `index.mdx` serves the directory root (`/docs`), `quick-start.mdx` serves `/docs/quick-start`, and `components/dialog.mdx` serves `/docs/components/dialog`.
**To add a new MDX page**, drop a file into `src/pages/docs/.mdx`; `contentRoutes` picks it up via the glob, with no `routes.ts` edit. (See `.claude/skills/add-docs-page.md` for the project-local skill.)
## View transitions
Route changes trigger a view transition automatically in browsers that support `document.startViewTransition`. See [View Transitions](/docs/view-transitions) for the full toolkit (named elements, lifecycle hooks, direction-driven types, and persistent elements).
## See also
- [The Route Table](/docs/routes): full reference for `defineRoutes`.
- [Layouts & Nested Routes](/docs/layouts): when and how to share chrome across URLs.
- [Server Loaders](/docs/loaders): what goes in the `.server.ts` file.
- [Middleware](/docs/middleware): the `use` field on a route node in `routes.ts` for auth gates and per-page middleware.
- [Active Links](/docs/active-links): linking between pages with active-state highlighting.
---
> Source: https://framework.sbesh.com/docs/head
# Head Management
Pages declare their document title, meta tags, link tags, and the `` attribute with head hooks imported from `hono-preact`. During SSR the framework collects every hook call made in the rendered tree and injects the tags into the document head, so titles and social metadata are present in the initial HTML; on the client the same hooks keep the head in sync as the user navigates.
## Example
Set a title and description from any page component:
```tsx
// src/pages/movie.tsx
import { useTitle, useMeta } from 'hono-preact';
export default function Movie({ movie }: { movie: { title: string } }) {
useTitle(movie.title);
useMeta({ name: 'description', content: `Details for ${movie.title}` });
return {movie.title} ;
}
```
Set a site-wide title template once in a layout, and page titles slot into it:
```tsx
// src/pages/layout.tsx
import { useTitleTemplate, useLang } from 'hono-preact';
export default function Layout({ children }) {
useTitleTemplate('%s | My App');
useLang('en');
return <>{children}>;
}
```
Add a link tag (a canonical URL, a preload, an icon):
```tsx
import { useLink } from 'hono-preact';
useLink({ rel: 'canonical', href: 'https://example.com/movies' });
```
## How it works
- **SSR injection.** `renderPage` collects every head hook call during prerender and post-processes the tags into your layout's ``. Your `Layout` must render a real `` element (the `` component from `hono-preact` provides one); with no `` in the output there is nowhere to inject and the tags are dropped.
- **Fallback title.** When no page sets a title, the `` prop (or `renderPage`'s `defaultTitle` option) supplies one.
- **Client navigation.** The hooks run on the client too: navigating to a page that calls `useTitle` updates `document.title` without a reload, and unmounting restores the previous value.
- **Deepest call wins.** When a layout and a page both set the same field, the innermost (most recently rendered) hook call takes effect, so page-level titles override layout defaults.
## API reference
| Hook | Signature | Description |
| ------------------ | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `useTitle` | `(title: string, template?: boolean) => void` | Sets `document.title`. Pass `template: true` to treat the string as a title template. |
| `useTitleTemplate` | `(template: string) => void` | Declares a title template; `%s` is replaced by the current `useTitle` value. |
| `useMeta` | `(options: MetaOptions) => void` | Renders a ` ` tag. `MetaOptions` carries `name`, `property` (Open Graph), `httpEquiv`, `charset`, and `content`. |
| `useLink` | `(options: LinkOptions) => void` | Renders a ` ` tag. `LinkOptions` carries `rel` (required), `href`, `as`, `media`, `sizes`, `crossorigin`, `type`, and `hreflang`. |
| `useLang` | `(language: string) => void` | Sets the `lang` attribute on ``. |
| `useScript` | `(options: ScriptOptions) => void` | Renders a `