What is conditional rendering?

Using conditional rendering, you can choose whether to display or hide certain blocks based on database properties.

How to render conditionally based on database properties?

To render conditionally, you will have to use toggle blocks. In the title of the toggle block, you have to use merge tags with if condition prefixed in the toggle heading section.

For the if condition to pass, the database property should be non-zero, or non empty value. If it is a checkbox, it should be checked.

  • {% if condition %}

    This block will be displayed if the condition property in the database is true or non zero or non empty value.

Use cases

  1. Render the Buy Now button if the stock is present
  2. Show discount block if the coupon code exist in the database property.


Hiding toggle blocks in Bullet

You can choose to hide toggle blocks in bullet using `bullet:Hide` as the title of the toggle block. 

When the title of the toggle block is "bullet:Hide" in the title of the toggle block, the entire toggle block will not be rendered in the website. You can use this to hide certain parts of the page that you want to use internally in Notion for managing site, but want to hide it in website.