> 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/zhan-dian-fang-wen/adaptive-content/adapting-your-content.md).

# 调整你的内容

设置好身份验证方法后，你就可以使用这些数据来为不同用户调整你网站中的内容。

你可以调整和个性化文档中的许多部分，包括：

* 隐藏或显示 [页面](/docs/documentation/zh/creating-content/content-structure/page.md)
* 隐藏或显示站点 [变体](/docs/documentation/zh/docs-site/site-structure/variants.md)
* 隐藏或显示站点 [章节](/docs/documentation/zh/docs-site/site-structure/site-sections.md)
* 隐藏或显示 [页眉链接](/docs/documentation/zh/docs-site/customization/layout-and-structure.md#header)
* 将个性化内容添加到 [行内表达式](/docs/documentation/zh/creating-content/variables-and-expressions.md)

### 使用条件编辑器

条件编辑器是你设置显示或隐藏页面、变体或章节条件的地方。打开条件编辑器后，你可以将条件编写为一个 [表达式](/docs/documentation/zh/creating-content/variables-and-expressions.md) ，该表达式会针对来自网站访客的数据运行。

<figure><img src="/files/96989d8868289027fecde7158837ccb215f61722" alt=""><figcaption></figcaption></figure>

#### 示例

你通过用户传递给 GitBook 的数据会附加到一个名为 `visitor.claims`.

如果我们想编写一个条件语句来 **仅向属于测试计划的用户显示页面** ，可以这样定义。

```javascript
visitor.claims.isBetaUser == true
```

上面的表达式表示，任何符合此声明的用户（即 `isBetaUser` 为 `true` ）都可以查看并访问该页面。不符合此声明的任何用户（包括未设置任何声明的访客）都无法查看或访问该页面。

条件编辑器还内置了自动补全功能，它会建议在你网站的先前访客中发现过的声明或属性，帮助你为页面、变体或章节编写条件语句。

使用自动补全时，你会注意到 [变量](/docs/documentation/zh/creating-content/variables-and-expressions.md#use-variables-in-your-content) 也可以使用。你可以将自己定义的变量与来自用户数据的声明组合起来，编写条件表达式。例如，你可以：

1. 为产品的最新版本设置一个变量
2. 然后，配置一个声明，用于显示访客正在使用你文档的哪个版本
3. 最后，编写一个表达式，仅在用户使用你文档的最新版本时显示某些页面

只要写法符合有效的 Javascript，你就可以编写许多不同类型的表达式。例如，你可以在条件编辑器中组合多个声明，使用 `&&` 或 `||` 运算符来匹配特定用户。你可以在 [这里](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators#binary_logical_operators).

### 使用分段进行测试

分段代表你可以配置来测试条件的模拟用户数据。

例如，你可以设置一个代表企业计划开发者，或免费计划登录用户的分段，然后查看哪些页面对他们可见。

[你可以在这里阅读更多关于设置和使用分段的信息。](/docs/documentation/zh/zhan-dian-fang-wen/adaptive-content/testing-with-segments.md)

### 条件页面

要为某个页面启动条件编辑器，请前往 <picture><source srcset="/files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="/files/d05670ba93b683794fb3fe95a9fc7ab5c7fceafd" alt="The Actions menu icon in GitBook"></picture> 页面旁边的操作菜单，并点击 **添加条件。** 你也可以从 [页面选项](/docs/documentation/zh/zi-yuan/gitbook-ui.md#page-options).

进入条件编辑器。若页面带有页面条件图标，你就可以看到该章节中哪些页面已设置条件 <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="/files/9462b24994b3e1c747496948ae8aafda4b33014f" alt="The Page condition icon in GitBook"></picture> 。

{% if visitor.claims.unsigned.bucket.IF\_BLOCK === true %}
**条件块**

要添加条件块，请在编辑器中新起一行，输入 <kbd>/</kbd>，然后选择 <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="/files/9462b24994b3e1c747496948ae8aafda4b33014f" alt="The Page condition icon in GitBook"></picture> **条件内容**.

在该块的右上角，点击 <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="/files/9462b24994b3e1c747496948ae8aafda4b33014f" alt="The Page condition icon in GitBook"></picture> **条件** 按钮来编辑条件并控制该块的可见性。并非所有块类型都支持条件块。
{% endif %}

### 条件变体

要为某个变体启动条件编辑器，请前往 <picture><source srcset="/files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="/files/d05670ba93b683794fb3fe95a9fc7ab5c7fceafd" alt="The Actions menu icon in GitBook"></picture> 变体旁边的操作菜单，并点击 **添加条件**.

如果变体带有页面条件图标，你就可以看到文档中哪些变体已设置条件 <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="/files/9462b24994b3e1c747496948ae8aafda4b33014f" alt="The Page condition icon in GitBook"></picture> 。

### 条件章节

要为某个章节启动条件编辑器，请前往 <picture><source srcset="/files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="/files/d05670ba93b683794fb3fe95a9fc7ab5c7fceafd" alt="The Actions menu icon in GitBook"></picture> 章节旁边的操作菜单，并点击 **添加条件**.

如果章节带有页面条件图标，你就可以看到文档中哪些章节已设置条件 <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="/files/9462b24994b3e1c747496948ae8aafda4b33014f" alt="The Page condition icon in GitBook"></picture> 。

### 条件页眉链接

要为某个页面页眉链接启动条件编辑器，请前往 <picture><source srcset="/files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="/files/d05670ba93b683794fb3fe95a9fc7ab5c7fceafd" alt="The Actions menu icon in GitBook"></picture> 页眉链接旁边的操作菜单，并点击 **添加条件**.

如果链接所在章节带有页面条件图标，你就可以看到文档中哪些链接已设置条件 <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="/files/9462b24994b3e1c747496948ae8aafda4b33014f" alt="The Page condition icon in GitBook"></picture> 。

### 行内表达式

除了控制内容的可见性外，你还可以使用 [表达式](/docs/documentation/zh/creating-content/variables-and-expressions.md)像页面和空间变量一样在行内使用声明。

要使用表达式在行内引用某个声明，请在编辑器中输入 <kbd>/</kbd> ，然后选择 <picture><source srcset="/files/HArsBmu3qFWO2SuJx7oR" media="(prefers-color-scheme: dark)"><img src="/files/42577c22593af29e4a47297915dcaa4ef592958b" alt=""></picture> **表达式**。在表达式编辑器中，声明将作为 `visitor` .

### 使用 Git Sync

在 GitBook 中设置的条件会通过 Git Sync 同步，并显示在同步的 Markdown 页面中。这意味着，设置了可见性条件的块和页面在你同步的仓库中仍然可见。

通过声明传递的数据绝不会显示在 Markdown 中，并会安全地传递给 GitBook。


---

# 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/zhan-dian-fang-wen/adaptive-content/adapting-your-content.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.
