> 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/fr/creer-du-contenu/blocks/conditional-content.md).

# Contenu conditionnel

Les blocs de contenu conditionnel vous permettent de contrôler qui peut voir un bloc de contenu donné sur votre page en fonction des données utilisateur et des variables. Ces variables peuvent être transmises via des cookies, des indicateurs de fonctionnalité, un accès authentifié ou des paramètres d’URL.

### Créer du contenu conditionnel

Pour ajouter un bloc conditionnel, commencez une nouvelle ligne dans l’éditeur et saisissez <kbd>/</kbd>, puis sélectionnez <picture><source srcset="/files/QtQtLiYwc1oJj119cgUz" media="(prefers-color-scheme: dark)"><img src="https://3903131528-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2F51vQZhUqnkdsYpyUo1Pj%2Fpage-condition.svg?alt=media&amp;token=31dd334a-5097-4081-915c-db460e610ec6" alt="The Page condition icon in GitBook"></picture> **Contenu conditionnel**.

Après avoir inséré le bloc, cliquez sur l’insigne rouge de condition en haut à droite du bloc.

En cliquant dessus, vous pourrez ajouter une condition via l’ [éditeur de conditions](/docs/documentation/fr/publish/adaptive-content/adapting-your-content.md#working-with-the-condition-editor). Vous pourrez écrire votre condition sous forme d’ [expression](/docs/documentation/fr/creer-du-contenu/variables-and-expressions.md) qui s’exécutera sur les données définies dans votre site. Vous pouvez faire référence à des données provenant de [variables](/docs/documentation/fr/creer-du-contenu/variables-and-expressions.md), ou à des données provenant des visiteurs via leurs [revendications](/docs/documentation/fr/publish/adaptive-content/enabling-adaptive-content.md#set-your-visitor-schema).

Vous pouvez également cibler les visiteurs humains ou les agents IA. Voir [ciblage des visiteurs humains et des agents IA](/docs/documentation/fr/publish/adaptive-content/adapting-your-content.md#target-human-visitors-and-ai-agents).

Voir [contenu adaptatif](/docs/documentation/fr/publish/adaptive-content.md) pour plus de détails.

### Exemple

Les exemples ci-dessous utilisent un paramètre d’URL lié au bouton pour contrôler quel bloc de contenu conditionnel est visible.

Ce bloc n’est visible que pour les utilisateurs **sans** l’attribut A.

<a href="https://gitbook.com/docs/create-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">Voir avec l’attribut A</a>

## Représentation en Markdown

```markdown
## Exemple

{% if visitor.claims.unsigned.example_attribute_A %}
Ce bloc n’est visible que pour les utilisateurs **avec** l’attribut A.
<a href="https://gitbook.com/docs/create-content/blocks/conditional-content?visitor.example_attribute_A=false" class="button primary">Voir sans l’attribut A</a>
{% endif %}

{% if !visitor.claims.unsigned.example_attribute_A %}
Ce bloc n’est visible que pour les utilisateurs **sans** l’attribut A.
<a href="https://gitbook.com/docs/create-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">Voir avec l’attribut 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/fr/creer-du-contenu/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.
