---
title: i18n and AI-friendly URLs
description: Middleware, locale prefixes, and SemanticGraph routes for multilingual sites.
canonical_url: https://next-ai-ready.vercel.app/en/docs/guides/i18n-ai-urls
url: https://next-ai-ready.vercel.app/en/docs/guides/i18n-ai-urls
last_updated: 2026-08-01
updated: 2026-08-01
author: next-ai-ready team
summary: Middleware, locale prefixes, and SemanticGraph routes for multilingual sites.
topics: [how-to, best-practices]
---

# i18n and AI-friendly URLs

`next-ai-ready` scans MDX from your `content` globs and maps file paths to routes. For multilingual sites, include the locale in the route (for example `/en/docs/install`).

## Recommended content layout

```text
content/
  en/
    docs/
      introduction.mdx
      installation.mdx
      guides/quickstart.mdx
  zh/
    docs/
      introduction.mdx
```

```js
// ai-ready.config.mjs
export default defineConfig({
  content: ["content/{en,zh}/**/*.mdx"],
});
```

Recognized route prefixes such as `en` and `zh` are stored in each page node's `locale` field. The generated `SemanticGraph.routesByLocale` index also maps locale-relative routes back to their page ids, while the flat `routes` map remains available for compatibility.

MCP page results expose the page locale. `list_pages` and `search_pages` do not yet accept a locale filter, so clients should use route prefixes when narrowing multilingual results.

## Middleware

If you redirect `/docs` → `/en/docs`, exclude AI artifact paths from the matcher so crawlers and agents can fetch them without redirects:

```ts
export const config = {
  matcher: [
    "/((?!_next|_ai-ready|api|.*\\..*).*)",
  ],
};
```

Patterns to keep reachable:

- `/_ai-ready/*` — framework handlers (`llms.txt`, `openapi.json`, …)
- `*.md`, `*.ai.json` — rewritten by `withAiReady()` to `/_ai-ready/*`
- `/llms.txt`, `/openapi.json`, `/tools.json`, `/.well-known/ai-plugin.json`

## llms.txt curation

Use `sections` in config to prioritize one locale in `llms.txt`, or emit separate configs per deployment.

## Current limits

Automatic `Available Languages` sections, alternate-language Markdown frontmatter, `hreflang` response links, and MCP locale filtering remain planned. See the [Phase 6 design](https://github.com/mustcanbedo/next-ai-ready/blob/main/docs/phase6-design.md) for the current boundary.
