Adapting your content

Tailor your content for different users.

After setting up your authentication method, you’ll be able to use the data to adapt the content in your site for different users.

Adaptive content works in the following ways:

  • Hiding or showing pages

  • Hiding or showing site variants

  • Hiding or showing site sections

Working with the condition editor

The condition editor is where you’ll set the conditions for showing or hiding a page, variant, or section. After opening the condition editor, you’ll be able to type a condition that will run against visitors to your site.

Example

The data you pass through your users to GitBook is attached to an object called visitor.claims.

Let’s take a look at an example if we want to write a conditional statement to only show a page for users who are part of a beta program you might define.

visitor.claims.isBetaUser == true

The condition above means that any user who matches this claim (i.e. isBetaUser is true in the user’s claim), will be able to see and access the page. Any user who does not match this claim (including visitors without any claims set), will not be able to see or access the page.

The condition editor also comes built in with autocomplete, which suggests claims or attributes that have been found on previous visitors to your site, helping you craft the conditional statement for your pages, variants, or sections.

You can combine multiple claims into the condition editor to match specific users by using the && or || operator. You can read more about operators here.

Conditional pages

Conditional variants

Conditional sections

Last updated

Was this helpful?