> 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%2F2cQxJ5sTMVUkXOcuDEU8%2FAdding%20a%20section%402x.png?alt=media&amp;token=2bd96c5f-0945-4d86-a835-a94102e627d9" alt="A GitBook screenshot showing a docs site&#x27;s structure"><figcaption></figcaption></figure>

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

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

{% hint style="info" %}
变体可以包含任何内容，但建议将其用作 *相同内容的不同版本*。如果您的内容在语义上不同，请考虑将其添加为 [章节](/docs/documentation/zh/manage-your-site/site-structure/site-sections.md) 代替。
{% endhint %}

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

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

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

从以下位置打开结构编辑器 **站点结构** 在站点侧边栏中。您可以在此查看站点的全部内容。

要添加变体，请单击 **添加变体** 按钮，在您想添加到的部分中，然后选择要添加的内容。新变体随后会被添加到所选部分内的变体列表中，并可供访问者在您站点上的变体下拉菜单中使用。

### 更改变体

您可以通过单击 <picture><source srcset="/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%2FA3OfGjPkE5GnOQvN36jN%2Fedit.svg?alt=media&amp;token=6f70239f-d889-4e64-9ec6-4801df47a48d" alt="The Edit icon in GitBook"></picture> **编辑** 按钮来更改每个变体的名称和 slug，该按钮位于您想编辑的变体所在的表格行中。这将打开一个弹窗。编辑您想更改的字段，然后单击 **保存** 按钮以保存。您也可以通过单击 **删除变体** 按钮，位于左下角。

如果您的站点支持多种语言，您还可以翻译变体标题，以便选择器显示本地化标签。参见 [多语言分区](/docs/documentation/zh/manage-your-site/site-structure/multilingual-sections.md).

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

要替换某个变体的内容，请先通过单击其 **编辑** <picture><source srcset="/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%2FA3OfGjPkE5GnOQvN36jN%2Fedit.svg?alt=media&amp;token=6f70239f-d889-4e64-9ec6-4801df47a48d" alt="The Edit icon in GitBook"></picture> 按钮将其删除，然后点击 **删除** 按钮，在弹窗左下角将其删除。一旦删除了该变体，请单击 **添加变体** 按钮以添加新内容。

### 重新排序变体

您的站点会按它们在您的 **站点结构** 表格中出现的顺序显示变体。变体可以通过抓住 **拖拽手柄** <picture><source srcset="/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%2FaS1QvPIBVYwhpFTGcPBN%2Foptions-menu.svg?alt=media&amp;token=3ee40bbf-f4fb-41fa-aa30-306b559cbe88" alt="The Options menu icon in GitBook"></picture> 并上下移动来重新排序。更改后的顺序会立即反映在你的网站上。

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

### 设置默认变体

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

要将某个变体设为默认，请单击 **操作菜单** <picture><source srcset="/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%2F89MTSo5XRpPMVr1T0rxS%2Factions.svg?alt=media&amp;token=2b5d001e-560a-4f29-8d22-de8163725ca1" 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="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2F89MTSo5XRpPMVr1T0rxS%2Factions.svg?alt=media&amp;token=2b5d001e-560a-4f29-8d22-de8163725ca1" alt="The Actions menu icon in GitBook"></picture> 打开该变体的结构编辑器，并选择 **移除**.

{% hint style="success" %}
从您的站点中移除变体会将其从已发布站点中删除，但 **不会删除内容本身** ——你仍然可以在 [全部内容](/docs/documentation/zh/create-content/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/manage-your-site/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.
