# Conditional content

Conditional content blocks let you control who can see a given block of content on your page based on user data and variables. These variables can be passed in via cookies, feature flags, authenticated access, or URL parameters.

### Create conditional content

To add a conditional block, begin a new line in the editor, type <kbd>/</kbd>, then select <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="/files/8HufkkEJzusqztntQZnK" alt="The Page condition icon in GitBook"></picture> **Conditional content**.

After inserting the block, click the red condition badge in the top right of the block.

Clicking this will allow you to add a condition through the [condition editor](/docs/site-access/adaptive-content/adapting-your-content.md#working-with-the-condition-editor). You’ll be able to write your condition as an [expression](https://gitbook.com/docs/creating-content/variables-and-expressions) that will run against data defined in your site. You can reference data from [variables](/docs/creating-content/variables-and-expressions.md), or data coming from visitors through their [claims](/docs/site-access/adaptive-content/enabling-adaptive-content.md#set-your-visitor-schema).

See [adaptive content](/docs/site-access/adaptive-content.md) for more details.

### Example

The examples below use a URL parameter linked from the button to control which conditional content block is visible.

{% if visitor.claims.unsigned.example\_attribute\_A %}
This block is only visible to users **with** attribute A.

<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=false" class="button primary">View without attribute A</a>
{% endif %}

{% if !visitor.claims.unsigned.example\_attribute\_A %}
This block is only visible to users **without** attribute A.

<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">View with attribute A</a>
{% endif %}

## Representation in Markdown

```markdown
## Example

{% if visitor.claims.unsigned.example_attribute_A %}
This block is only visible to users **with** attribute A.
<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=false" class="button primary">View without attribute A</a>
{% endif %}

{% if !visitor.claims.unsigned.example_attribute_A %}
This block is only visible to users **without** attribute A.
<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">View with attribute 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/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.
