> 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/guan-li-ni-de-zhan-dian/site-structure/variants.md).

# 内容变体

你可以将同一文档的多个版本作为单个文档站点的一部分发布。这些变体会通过已发布站点目录顶部的变体选择器供最终用户使用。

<figure><img src="/files/9e6bf239f3a1ba2f1b788524e6b798a75928ede1" alt="A GitBook screenshot showing a docs site&#x27;s structure"><figcaption></figcaption></figure>

### 添加多种语言或版本

如果你需要将内容的不同变体放在一起，一个包含多个变体的站点会很有用——例如，你在记录一个 API 的多个版本（v1、v2、v3 等），或者用不同语言记录你的内容。

{% hint style="info" %}
变体可以包含任何内容，但建议将其用作 *同一内容的不同变体*。如果你的内容在语义上不同，建议将其添加为 [部分中](/docs/documentation/zh/guan-li-ni-de-zhan-dian/site-structure/site-sections.md) 。
{% endhint %}

当将翻译或多种语言作为变体添加时，最佳实践是为变体设置语言，以便用户在浏览文档时获得最佳体验。

添加多个已设置语言的变体后，语言选择器会移到右上角，相比默认的变体选择器，提供更简洁、更直接的体验。

### 向你的文档站点添加变体

从以下位置打开结构编辑器 **站点结构**，在 **常规** 在站点侧边栏中。在这里你可以看到站点的所有内容。

要添加变体，请点击 **添加变体** 你想添加到的部分中的按钮，然后选择要添加的内容。新的变体随后会添加到所选部分内的变体列表中，并会在你站点的变体下拉菜单中向访问者显示。

### 更改变体

你可以通过点击 <picture><source srcset="/files/kN09oTFtAuyaxNIwWuCt" media="(prefers-color-scheme: dark)"><img src="/files/ffffa8d3208c93af4ead7061897fa70e6d0d612f" alt="The Edit icon in GitBook"></picture> **编辑** 你想编辑的变体所在行中的按钮，来更改每个变体的名称和 slug。这将打开一个模态框。编辑你想更改的字段，然后点击 **保存** 按钮以保存。你也可以通过点击 **删除变体** 左下角的按钮。

如果你的站点支持多种语言，你还可以翻译变体标题，使选择器显示本地化标签。参见 [多语言章节](/docs/documentation/zh/guan-li-ni-de-zhan-dian/site-structure/multilingual-sections.md).

{% hint style="info" %}
更改变体的 slug 会改变其规范 URL。GitBook 会自动将旧 URL 重定向到新 URL。你也可以 [手动创建重定向](/docs/documentation/zh/fa-bu/site-redirects.md).
{% endhint %}

要替换变体的内容，首先通过点击其 **编辑** <picture><source srcset="/files/kN09oTFtAuyaxNIwWuCt" media="(prefers-color-scheme: dark)"><img src="/files/ffffa8d3208c93af4ead7061897fa70e6d0d612f" alt="The Edit icon in GitBook"></picture> 按钮将其删除，然后点击弹窗左下角的 **删除** 模态框左下角的按钮将其删除。删除变体后，点击 **添加变体** 按钮添加新内容。

### 重新排序变体

你的站点会按照它们在你的 **站点结构** 表格中出现的顺序显示变体。你可以通过拖动 **拖动手柄** <picture><source srcset="/files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="/files/e1df373962dc4830bcb786d7e5cb3cce603367d3" alt="The Options menu icon in GitBook"></picture> 中出现的顺序显示部分和变体。你可以抓住

你也可以使用键盘选择并移动内容：按空格键选择一个部分或变体，然后使用方向键将其上移或下移。再次按空格键以确认新位置。

### 设置默认变体

如果一个部分中有多个变体，其中一个会被标记为默认变体。访客进入你的站点时（或访问某个部分时）会显示该变体。其他变体各自都有一个会附加到站点 URL 末尾的 slug。

要将某个变体设为默认，请点击 **操作菜单** <picture><source srcset="/files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="/files/d05670ba93b683794fb3fe95a9fc7ab5c7fceafd" alt="The Actions menu icon in GitBook"></picture> 变体的表格行中，然后点击 **设为默认**.

{% hint style="info" %}
将某个变体设为默认后，它的 slug 字段将被移除，因为它将改为从该部分的根路径提供。GitBook 会将该变体的 slug 重定向到相应路径，以确保访客继续看到你的内容。
{% endhint %}

### 从站点中移除变体

要从站点中移除变体，请从 **站点结构**，在 **常规** 在站点侧边栏中打开结构编辑器，然后找到你想移除的内容。

打开 **操作菜单** <picture><source srcset="/files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="/files/d05670ba93b683794fb3fe95a9fc7ab5c7fceafd" alt="The Actions menu icon in GitBook"></picture> 针对你想移除的变体，然后选择 **移除**.

{% hint style="success" %}
从你的站点中移除变体会将其从已发布站点中移除，但 **不会删除内容本身** ——你仍然可以在 [全部内容](/docs/documentation/zh/chuang-jian-nei-rong/content-structure/all-content.md).
{% endhint %}


---

# 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/guan-li-ni-de-zhan-dian/site-structure/variants.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.
