> 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/ja-gitbook-documentation/publish/adaptive-content/adapting-your-content.md). Agents can also search and read this documentation through its [MCP server](https://gitbook.com/docs/~gitbook/mcp).

# コンテンツの適応

さまざまなユーザー向けにコンテンツを最適化します

認証方法を設定すると、そのデータを使ってサイト内のコンテンツをユーザーごとに調整できるようになります。

ドキュメントのさまざまな部分を調整してパーソナライズできます。たとえば次のようなものです。

* 表示・非表示の切り替え： [ページ](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/content-structure/page.md)
* サイトの表示・非表示の切り替え： [バリアント](https://gitbook.com/docs/documentation/ja-gitbook-documentation/manage-your-site/site-structure/variants.md)
* サイトの表示・非表示の切り替え： [セクション](https://gitbook.com/docs/documentation/ja-gitbook-documentation/manage-your-site/site-structure/site-sections.md)
* セクショングループの表示と非表示 [セクショングループ](https://gitbook.com/docs/documentation/ja-gitbook-documentation/manage-your-site/site-structure/site-sections.md#create-a-section-group)
* 表示・非表示の切り替え： [ヘッダーリンク](https://gitbook.com/docs/documentation/ja-gitbook-documentation/manage-your-site/customization/layout-and-structure.md#header)
* 表示・非表示 [ページアクション](https://gitbook.com/docs/documentation/ja-gitbook-documentation/manage-your-site/customization/extra-configuration.md#control-page-actions-with-adaptive-content)
* パーソナライズされたコンテンツの追加先： [インライン式](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/variables-and-expressions.md)

### 条件エディタの使い方

条件エディターでは、ページ、バリアント、セクションの表示・非表示を決める条件を設定します。条件エディターを開いたら、条件を [式](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/variables-and-expressions.md) として記述できます。この式は、サイトの訪問者から得られるデータに対して実行されます。

<figure><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-fcf2f2a37f5ca2fa97948447edec07e941ed4c31%2F22_01_06_condition_editor%402x.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 例

ユーザーを通じてGitBookに渡すデータは、次の名前のオブジェクトに付加されます： `visitor.claims`.

条件文の例を見てみましょう。たとえば、 **ベータプログラムに参加しているユーザーにのみページを表示する** 場合、次のように定義できます。

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

上記の式は、このクレームに一致するユーザー（つまり、ユーザーのクレームで `isBetaUser` が `true` であるユーザー）が、ページを閲覧してアクセスできることを意味します。このクレームに一致しないユーザー（クレームが設定されていない訪問者を含む）は、ページを閲覧することもアクセスすることもできません。

条件エディタにはオートコンプリートも組み込まれており、これまでのサイト訪問者から見つかったクレームや属性を提案してくれるため、ページ、バリアント、またはセクションの条件文を作成しやすくなります。

オートコンプリートを使用すると、 [変数](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/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).

### 人間の訪問者とAIエージェントを対象にする

組み込みの `visitor.type` プロパティを使用すると、人間とAIエージェントに異なるコンテンツを表示できます。このプロパティは次の2つの値のいずれかを取ります：

* `human` ：人間の訪問者
* `agent` ：AIエージェント

たとえば、この条件を使うとコンテンツをAIエージェントにのみ表示できます。

```javascript
visitor.type === "agent"
```

次の条件を使うとコンテンツを人間の訪問者にのみ表示できます。

```javascript
visitor.type === "human"
```

### セグメントを使ったテスト

セグメントは、条件をテストするために設定できるモックユーザーデータを表します。

たとえば、エンタープライズプランの開発者や無料プランのサインイン済みユーザーを表すセグメントを設定し、その人にどのページが表示されるかを確認できます。

[セグメントの設定と使用について詳しくは、こちらをご覧ください。](https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/testing-with-segments.md)

### 条件付きページ

ページの条件エディターを開くには、ページの横にあるアクションメニュー <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://4217681718-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> を開き、次の項目をクリックします： **条件を追加** 条件エディターは、 [ページのオプション](https://gitbook.com/docs/documentation/ja-gitbook-documentation/rifarensu/gitbook-ui.md#page-options).

から開くこともできます。セクション内で条件が設定されているページは、ページの条件アイコン <picture><source srcset="broken://files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-3a6138a731d7e8e493c54e04ac84e28d9e73ff33%2F25_04_10_page_condition_1.svg?alt=media" alt="The Page condition icon in GitBook"></picture> が横に表示されるため、確認できます。

### 条件付きバリアント

バリアントの条件エディターを開くには、 <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://4217681718-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> バリアントの横にあるアクションメニューを開き、 **条件を追加**.

バリアントの横にページ条件アイコンが表示されている場合、そのバリアントに条件が設定されていることを確認できます。 <picture><source srcset="broken://files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-3a6138a731d7e8e493c54e04ac84e28d9e73ff33%2F25_04_10_page_condition_1.svg?alt=media" alt="The Page condition icon in GitBook"></picture> 。

### 条件付きセクション

セクションの条件エディターを開くには、 <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://4217681718-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> セクションの横にあるアクションメニューを開き、 **条件を追加**.

セクションの横にページ条件アイコンが表示されている場合、そのセクションに条件が設定されていることを確認できます。 <picture><source srcset="broken://files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-3a6138a731d7e8e493c54e04ac84e28d9e73ff33%2F25_04_10_page_condition_1.svg?alt=media" alt="The Page condition icon in GitBook"></picture> 。

### 条件付きセクショングループ

セクショングループを表示できるユーザーを制御するには、 **サイト構成**を開き、グループの横にあるアクションメニュー <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://4217681718-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> を開いて、 **サイトオーディエンス**をクリックします。次のいずれかを選択します。

* **デフォルト**：サイト上の誰でもセクショングループにアクセスできます。
* **条件付き**：条件に一致するサイト訪問者のみがセクショングループにアクセスできます。

### 条件付きページヘッダーリンク

ページヘッダーリンクの条件エディターを開くには、 <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://4217681718-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> ヘッダーリンクの横にあるアクションメニューを開き、 **条件を追加**.

リンクの横にページ条件アイコンが表示されていれば、ドキュメント内で条件が設定されているリンクを確認できます。 <picture><source srcset="broken://files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-3a6138a731d7e8e493c54e04ac84e28d9e73ff33%2F25_04_10_page_condition_1.svg?alt=media" alt="The Page condition icon in GitBook"></picture> 。

### 条件付きページアクション

有効にしたページアクションは、条件に一致する訪問者にのみ表示できます。たとえば、次のアクションを表示できます。 **GitHub/GitLabで編集** 次の場合にのみ： `visitor.claims.isInternal === true`.

［ **サイトのカスタマイズ → ページアクション**］で、アクションを選択し、 **サイトのオーディエンス** を **条件付き**に設定します。GitBookでは、条件が設定されたアクションにアイコンが表示されます。カスタマイズプレビューで訪問者セグメントを指定して、結果をテストしてください。

**アシスタントを開く** は、条件付きオーディエンスに対応していません。詳しくは、 [ページアクション](https://gitbook.com/docs/documentation/ja-gitbook-documentation/manage-your-site/customization/extra-configuration.md#control-page-actions-with-adaptive-content).

### インライン式

コンテンツの表示を制御するだけでなく、ページ変数やスペース変数と同様に、 [式](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/variables-and-expressions.md)を使ってクレームをインラインで参照することもできます。

式を使ってクレームをインラインで参照するには、エディターで <kbd>/</kbd> と入力し、 <picture><source srcset="broken://files/HArsBmu3qFWO2SuJx7oR" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-0372c50d88715b1ce5bdd5385d27db9f36626105%2F25_07_23_expression.svg?alt=media" 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 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/ja-gitbook-documentation/publish/adaptive-content/adapting-your-content.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.
