> 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/manage-your-site/site-structure/variants.md).

# 内容变体

在一个站点中发布多个产品版本或语言的文档

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

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-aa4fe159ecc96a17143a21cba5208c1a140e21c1%2F25_12_10_adding_a_section%402x.png?alt=media" alt="A GitBook screenshot showing a docs site&#x27;s structure"><figcaption></figcaption></figure>

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

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

{% hint style="info" %}
变体可以包含任意内容，但建议将其用作 *同一内容的不同版本*。如果内容在语义上有所不同，请考虑将其添加为 [分区](https://gitbook.com/docs/documentation/zh/manage-your-site/site-structure/site-sections.md) 。
{% endhint %}

当将翻译或多种语言作为变体添加时，最佳做法是为您的变体设置语言，这样用户在浏览文档时能获得最佳体验。

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

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

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

要添加变体，请点击要添加变体的分区中的 **添加变体** 按钮，然后选择要添加的内容。新变体会添加到所选分区的变体列表中，访客也可以通过站点上的变体下拉菜单访问它。

### 更改变体

点击要编辑的变体所在表格行中的 <picture><source srcset="broken://files/kN09oTFtAuyaxNIwWuCt" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-d28f11ed4dfafb06aa9c6ae92db8017d94014317%2F25_01_10_edit_icon_light.svg?alt=media" alt="The Edit icon in GitBook"></picture> **编辑** 按钮，即可更改变体的名称和 slug。这会打开一个模态框。编辑要更改的字段，然后点击 **保存** 按钮即可保存。你也可以点击左下角的 **删除变体** 按钮来删除变体。

如果你的站点支持多种语言，也可以翻译变体标题，让选择器显示本地化标签。请参阅 [多语言分区](https://gitbook.com/docs/documentation/zh/manage-your-site/site-structure/multilingual-sections.md).

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

要替换变体内容，请先点击其 **编辑** <picture><source srcset="broken://files/kN09oTFtAuyaxNIwWuCt" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-d28f11ed4dfafb06aa9c6ae92db8017d94014317%2F25_01_10_edit_icon_light.svg?alt=media" alt="The Edit icon in GitBook"></picture> 按钮将其删除，然后点击模态框左下角的 **删除** 按钮。删除变体后，点击 **添加变体** 按钮即可添加新内容。

### 重新排序变体

站点会按照变体在 **站点结构** 表格中的顺序显示变体。抓住 **拖动手柄** <picture><source srcset="broken://files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-23f3e8f05326b0d239d32d28bba99c1d46f204f7%2F25_01_10_options_light.svg?alt=media" alt="The Options menu icon in GitBook"></picture> 并上下移动即可重新排序。顺序更改后会立即反映在站点上。

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

### 设置默认变体

如果某个部分中有多个变体，其中一个会被标记为默认变体。访问者进入您的站点（或访问某个部分）时会显示此变体。其他每个变体都有一个附加到站点 URL 的 slug。

要将某个变体设为默认变体，请点击该变体所在表格行中的 **操作菜单** <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-aabbca522107ef561981bdfe5af94605b31e0920%2F25_01_10_actions_icon_light.svg?alt=media" alt="The Actions menu icon in GitBook"></picture> ，然后点击 **设为默认**.

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

### 从站点中移除变体

要从站点中移除变体，请从站点侧边栏中的 **站点结构** 打开结构编辑器，并找到要移除的内容。

打开要移除的变体对应的 **操作菜单** <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-aabbca522107ef561981bdfe5af94605b31e0920%2F25_01_10_actions_icon_light.svg?alt=media" alt="The Actions menu icon in GitBook"></picture> ，然后选择 **移除**.

{% hint style="success" %}
从站点中移除变体会将其从已发布的站点中移除，但 **不会删除内容本身** ——你仍然可以在 [所有内容](https://gitbook.com/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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/zh/manage-your-site/site-structure/variants.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
