# 条件付きコンテンツ

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

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

条件付きブロックを追加するには、エディタで新しい行を開始し、 <kbd>/</kbd>と入力してから <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="/files/3d64f0529a83b9e1d7a5e924729ec63c1401a2dc" alt="The Page condition icon in GitBook"></picture> **条件付きコンテンツ**.

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

これをクリックすると、 [条件エディタ](/docs/documentation/ja-gitbook-documentation/saitoakusesu/adaptive-content/adapting-your-content.md#working-with-the-condition-editor)を通じて条件を追加できます。条件は、 [式](https://gitbook.com/docs/creating-content/variables-and-expressions) として記述でき、サイトで定義されたデータに対して実行されます。データは [変数](/docs/documentation/ja-gitbook-documentation/creating-content/variables-and-expressions.md)から、または訪問者からその [を通じて送られてくるデータを参照できます。](/docs/documentation/ja-gitbook-documentation/saitoakusesu/adaptive-content/enabling-adaptive-content.md#set-your-visitor-schema).

参照 [アダプティブコンテンツ](/docs/documentation/ja-gitbook-documentation/saitoakusesu/adaptive-content.md) を参照してください。

### 例

以下の例では、ボタンからリンクされた URL パラメータを使用して、どの条件付きコンテンツブロックを表示するかを制御しています。

{% if visitor.claims.unsigned.example\_attribute\_A %}
このブロックは、 **を持つユーザーにのみ表示されます。** 属性 A

<a href="https://gitbook.com/docs/creating-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/creating-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">属性 A ありで表示</a>
{% endif %}

## Markdown での表現

```markdown
## 例

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


---

# Agent Instructions: 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:

```
GET https://gitbook.com/docs/documentation/ja-gitbook-documentation/creating-content/blocks/conditional-content.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
