---
title: 配置
description: 在 ai-ready.config.mjs 中配置站点元数据、内容目录、Actions、robots 策略与生成产物。
canonical_url: https://nextaiready.com/zh/docs/api-reference/config
url: https://nextaiready.com/zh/docs/api-reference/config
last_updated: 2026-09-26
updated: 2026-09-26
author: next-ai-ready 团队
summary: 在 ai-ready.config.mjs 中配置站点元数据、内容目录、Actions、robots 策略与生成产物。
topics: [api, reference, 内容目录, 站点选项]
---

# 配置

`ai-ready.config.mjs` 是配置 `next-ai-ready` 的唯一入口文件，位于项目根目录。

也可以使用 `ai-ready.config.ts`。加载器使用 `jiti`，它会作为 `@next-ai-ready/next` 的运行时依赖随 meta 包安装，消费者无需单独添加。

## defineConfig

```js
import { defineConfig } from "next-ai-ready";

export default defineConfig({
  site: { ... },
  content: [ ... ],
  actions: "./actions/index.mjs",
  emit: { ... },
});
```

## site

站点级元数据，用于 `llms.txt`、OpenAPI 和 JSON-LD。

| 字段            | 类型       | 必填 | 描述                        |
| ------------- | -------- | -- | ------------------------- |
| `name`        | `string` | 是  | 站点或产品名称                   |
| `baseUrl`     | `string` | 是  | 生产环境 URL（用于 canonical 链接） |
| `description` | `string` | 是  | 面向 AI 消费者的简短描述            |

## content

指向 MDX 内容文件的 glob 模式数组：

```js
content: ["app/**/*.mdx", "content/**/*.mdx"]
```

这些文件在 `next-ai-ready build` 时被扫描，生成语义图谱、`llms.txt` 和逐页 Markdown/JSON。

## actions

Action 模块路径，相对于配置文件解析：

```js
actions: "./actions/index.mjs"
```

该模块应导出一个 `defineActions(...)` 包裹的 `defineAction(...)` 调用数组：

```js
import { defineActions, defineAction } from "next-ai-ready";
export default defineActions([ ... ]);
```

## emit

控制生成哪些产出物：

| 字段        | 类型        | 默认值    | 描述                                                 |
| --------- | --------- | ------ | -------------------------------------------------- |
| `openapi` | `boolean` | `true` | 生成 `/openapi.json`、`/tools.json`、`/ai-plugin.json` |

## robots

控制构建是否生成 `public/robots.txt`，并决定已知 AI Agent 的访问策略。原来的统一写法继续
兼容：

```js
robots: {
  aiBots: "allow", // 或 "disallow"
  sitemap: true,
}
```

当搜索可见性与模型训练策略不同时，使用按用途分类的写法：

```js
robots: {
  aiBots: {
    search: "allow",
    user: "allow",
    training: "disallow",
    other: "allow",
  },
  sitemap: true,
}
```

| 字段        | 类型                                     | 默认值       | 描述                                                                     |
| --------- | -------------------------------------- | --------- | ---------------------------------------------------------------------- |
| `aiBots`  | `"allow" \| "disallow" \| AiBotPolicy` | `"allow"` | 对所有已知 bot 使用统一策略，或分别设置 `search`、`training`、`user`、`other` 和 `default`。 |
| `sitemap` | `boolean \| string`                    | `false`   | 使用默认或指定 URL 生成 sitemap 声明。                                             |
| `extra`   | `string[]`                             | `[]`      | 在静态输出末尾添加原始指令；结构化 `aiRobots()` 不支持该字段。                                 |

各服务商用途、`app/robots.ts` 类型化示例和不同决策的可见性影响见
[robots.txt 指南](../guides/robots-txt)。
