> 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/docs-site/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/docs-site/site-structure/site-sections.md) 代替。
{% endhint %}

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

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

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

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

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

### 更改变体

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

如果你的网站支持多种语言，你还可以翻译变体标题，这样选择器就会显示本地化标签。参见 [多语言章节](/docs/documentation/zh/docs-site/site-structure/multilingual-sections.md).

{% hint style="info" %}
更改变体的 slug 会改变其规范 URL。GitBook 会自动将旧 URL 重定向到新 URL。你还可以 [手动创建重定向](/docs/documentation/zh/docs-site/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/creating-content/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/docs-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.
