> 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/kontentsuwosuru/blocks/conditional-content.md).

# 条件付きコンテンツ

条件付きコンテンツブロックを使うと、ユーザーデータや変数に基づいて、ページ上の特定のコンテンツブロックを誰に表示するかを制御できます。これらの変数は、Cookie、機能フラグ、認証済みアクセス、URLパラメータを通じて渡すことができます。

### 条件付きコンテンツを作成する

条件付きブロックを追加するには、エディターで新しい行を開始して次のように入力し、 <kbd>/</kbd>、次の項目を選択します： <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> **条件付きコンテンツ**.

ブロックを挿入したら、ブロックの右上にある赤い条件バッジをクリックします。

クリックすると、 [条件エディター](https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/adapting-your-content.md#working-with-the-condition-editor)を使って条件を追加できます。条件は [式](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)のデータや、訪問者から送信される [クレーム](https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/enabling-adaptive-content.md#set-your-visitor-schema).

を参照できます。人間の訪問者またはAIエージェントをターゲットにすることもできます。詳しくは、 [人間の訪問者とAIエージェントをターゲットにする](https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/adapting-your-content.md#target-human-visitors-and-ai-agents).

、 [適応型コンテンツ](https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content.md) をご覧ください。

### 例

以下の例では、ボタンにリンクされたURLパラメータを使って、表示する条件付きコンテンツブロックを切り替えています。

このブロックは、属性Aを **持たない** ユーザーにのみ表示されます。

<a href="https://gitbook.com/docs/create-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">属性Aありで表示</a>

## Markdownでの表現

```markdown
## 例

{% if visitor.claims.unsigned.example_attribute_A %}
このブロックは、属性Aを**持つ**ユーザーにのみ表示されます。
<a href="https://gitbook.com/docs/create-content/blocks/conditional-content?visitor.example_attribute_A=false" class="button primary">属性Aなしで表示</a>
{% endif %}

{% if !visitor.claims.unsigned.example_attribute_A %}
このブロックは、属性Aを**持たない**ユーザーにのみ表示されます。
<a href="https://gitbook.com/docs/create-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">属性Aありで表示</a>
{% endif %}
```


---

# 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/kontentsuwosuru/blocks/conditional-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.
