# 内容配置

如果你想进一步配置 Git 同步，可以添加一个 `.gitbook.yaml` 文件到仓库根目录，以告诉 GitBook 如何解析你的 Git 仓库。

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

```yaml
root: ./

​结构：
  readme: README.md
  summary: SUMMARY.md​

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

{% endcode %}

### 根目录

用于查找文档的路径默认指向仓库的根目录。你可以这样告诉 GitBook 去查看一个 `./docs` 文件夹：

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

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

{% endcode %}

{% hint style="warning" %}
**其他所有指定路径的选项都将相对于此根文件夹。**。因此，如果你将 root 定义为 `./docs/` 然后将 `structure.summary` 设置为 `./product/SUMMARY.md`，GitBook 实际上会查找位于 `./docs/product/SUMMARY.md`。‌
{% endhint %}

### ​结构‌ <a href="#structure" id="structure"></a>

结构接受两个属性：‌

* **`readme`**：你的文档的第一页。其默认值为 `./README.md`
* **`summary`**：你的文档目录。其默认值为 `./SUMMARY.md`

这些属性的值是对应文件的路径。该路径相对于“root”选项。例如，你可以这样告诉 GitBook 去查看一个 `./product` 文件夹中的首页和摘要：

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

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

{% endcode %}

{% hint style="warning" %}
当启用 Git 同步时， **请记得不要通过 GitBook 的界面创建或修改 readme 文件** 。readme 文件应当专门在你的 GitHub/GitLab 仓库中管理，以避免冲突和重复问题。
{% endhint %}

### 摘要‌ <a href="#summary" id="summary"></a>

该 `summary` 文件是一个 Markdown 文件（`.md`），其应具有以下结构：

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

```markdown
‌# 摘要​

## 使用标题创建这样的页面组​

* [第一页标题](page1/README.md)
    * [某个子页面](page1/page1-1.md)
    * [其他子页面](part1/page1-2.md)

* [第二页标题](page2/README.md)
    * [某个子页面](page2/page2-1.md)
    * [其他子页面](part2/page2-2.md)

## 第二页组​

* [另一个页面](another-page.md)
```

{% endcode %}

提供自定义摘要文件是可选的。默认情况下，GitBook 会在 `SUMMARY.md` 中查找名为 `root` 的文件，如果你的配置文件中指定了该文件夹；否则则在仓库根目录中查找。

如果你没有指定摘要，并且 GitBook 没有在你的文档根目录中找到一个 `SUMMARY.md` 文件，GitBook 将根据文件夹结构和下面的 Markdown 文件推断目录。‌

{% hint style="info" %}
摘要 markdown 文件是 **与你的** **目录** 的镜像。因此，即使在首次导入时未提供摘要文件，只要你使用 GitBook 编辑器更新内容，GitBook 也会创建一个和/或更新它。

因此，在你的 `SUMMARY.md` 文件中无法两次引用同一个 Markdown 文件，因为这会意味着 GitBook 空间中的同一页面存在于两个不同的 URL。
{% endhint %}

#### 目录（侧边栏）标题 <a href="#sidebar-titles" id="sidebar-titles"></a>

如果你希望页面在目录侧边栏中的标题与页面本身不同，你可以定义一个可选的 **页面链接标题** 中查找名为 `SUMMARY.md` 文件的子目录。

如果你使用 Git 同步，页面链接标题会设置在页面链接上：

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

```markdown
# Summary

* [页面主标题](page.md "页面链接标题")
```

{% endcode %}

引号内的文本（`"页面链接标题"`）将会用于：

* 在目录（侧边栏）中
* 在每个页面底部的分页按钮中
* 在你添加到该页面的任何相对链接中

页面链接标题是可选的——如果你不手动添加，GitBook 默认会在各处使用页面的标准标题。


---

# Agent Instructions: 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:

```
GET https://gitbook.com/docs/documentation/zh/getting-started/git-sync/content-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
