> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/wen-dang-ji-dai-ma/git-sync/content-configuration.md).

# 内容配置

Git Sync 使用三个文件。请选择控制您所需的 Git Sync 部分的文件：

* `docs.yaml` 配置站点并将空间映射到仓库目录。
* `.gitbook.yaml` 配置 GitBook 如何读取一个空间的内容。
* `SUMMARY.md` 定义一个空间的导航。

### 使用 docs.yaml 配置站点

`docs.yaml` 用于配置整个站点。它位于 Git Sync 项目目录中。若未设置项目目录，GitBook 将使用仓库根目录。 **项目目录**.

使用 `docs.yaml` 以定义您的站点结构，并将每个空间映射到一个目录。位于 `site.structure` 具有稳定的 `键`。一个空间的 `content.directory` 设置其仓库目录。

此示例将英语和法语空间映射到不同的目录：

{% code title="docs.yaml" expandable="true" %}

```yaml
$schema: https://api.gitbook.com/openapi.yaml#/components/schemas/GitSyncSiteConfig
site:
  title: 文档
  structure:
    - type: section
      key: documentation
      title: 文档
      path: documentation
      children:
        - type: space
          key: docs-en
          title: 英语
          path: docs
          default: true
          content:
            directory: ./docs/en
            language: en
        - type: space
          key: docs-fr
          title: Français
          path: fr
          content:
            directory: ./docs/fr
            language: fr
```

{% endcode %}

<details>

<summary>配置额外的站点属性</summary>

使用这些可选属性来细化您的站点结构：

| 属性                     | 用途                |
| ---------------------- | ----------------- |
| `type: section-group`  | 将相关章节分组到共享的导航标题下。 |
| `description`          | 为章节添加描述。          |
| `icon`                 | 为章节或章节组添加图标。      |
| `localizedTitle`       | 翻译章节、章节组或空间标题。    |
| `localizedDescription` | 翻译章节描述。           |
| `hidden`               | 从站点导航中隐藏一个空间。     |

GitBook 会创建或更新 `docs.yaml` 当它保存站点内容映射时。

</details>

### 使用 .gitbook.yaml 配置空间

`.gitbook.yaml` 用于配置一个空间。它位于该空间映射后的目录中。可用于设置内容根目录、第一页、导航文件和重定向。

主要设置如下：

* `root` 设置 GitBook 读取的目录。其默认值为 `./`.
* `structure.readme` 设置第一页。其默认值为 `README.md`.
* `structure.summary` 设置导航文件。其默认值为 `SUMMARY.md`.
* `redirects` 将空间内的旧路径映射到新路径。

这是一个典型的配置示例：

{% code title=".gitbook.yaml" %}

```yaml
root: ./

structure:
  readme: README.md
  summary: SUMMARY.md

redirects:
  previous/page: new-folder/page.md
```

{% endcode %}

#### 设置内容根目录

设置 `root` 当一个空间的内容位于子目录中时：

{% code title=".gitbook.yaml" %}

```yaml
root: ./docs/
```

{% endcode %}

{% hint style="warning" %}
中的路径 `.gitbook.yaml` 相对于 `root`。使用 `root: ./docs/`, `structure.summary: ./product/SUMMARY.md` 会解析为 `./docs/product/SUMMARY.md`.
{% endhint %}

在单体仓库中， `root` 仅适用于已映射的空间目录内。它不会使兄弟目录变为可用。有关多空间仓库设置，请参见 [单体仓库](/docs/documentation/zh/wen-dang-ji-dai-ma/git-sync/monorepos.md).

#### 设置第一页和导航文件

使用 `structure.readme` 和 `structure.summary` 以设置自定义文件路径：

{% code title=".gitbook.yaml" %}

```yaml
structure:
  readme: ./product/README.md
  summary: ./product/SUMMARY.md
```

{% endcode %}

{% hint style="warning" %}
启用 Git Sync 时，请管理 `README.md` 仓库中的文件。在 GitBook 中编辑它们可能会产生冲突或重复页面。
{% endhint %}

#### 配置重定向

在 `.gitbook.yaml`中配置空间级重定向。重定向路径仅适用于该空间内。

您也可以在 GitBook 应用中管理站点级重定向。请参见 [站点重定向](/docs/documentation/zh/fa-bu/site-redirects.md).

### 使用 SUMMARY.md 配置导航

`SUMMARY.md` 定义一个空间的目录。GitBook 会在已配置的 `root` 目录中查找它。

如果 GitBook 没有找到 `SUMMARY.md`，它会根据您的文件夹和 Markdown 文件推断导航。GitBook 会创建或更新 `SUMMARY.md` 当您在 GitBook 中更改导航时。

将标题用于页面分组，并将嵌套链接用于子页面：

{% code title="SUMMARY.md" %}

```markdown
# 摘要

## 产品

* [概览](README.md)
  * [入门](getting-started.md)
  * [配置](configuration.md)

## 参考

* [API 参考](api.md)
```

{% endcode %}

每个 Markdown 文件在 `SUMMARY.md`中只能出现一次。一个页面在一个空间中只能有一个 URL。

#### 设置导航标签

当导航标签与页面标题不同时，为页面链接添加标题：

{% code title="SUMMARY.md" %}

```markdown
# 摘要

* [页面主标题](page.md "导航标签")
```

{% endcode %}

GitBook 会在侧边栏、分页和相对链接中使用页面链接标题。若未设置，GitBook 会使用页面标题。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gitbook.com/docs/documentation/zh/wen-dang-ji-dai-ma/git-sync/content-configuration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
