I have a boolean field within my Page content type called Hide Title.
I need to conditionally add a class to h1’s to visually hide them if this field is checked.
I have the following within page-title.html.twig
{% set hide_title = content.field_hide_title.0 %} {% if 'On' in hide_title %} <h1 {{ title_attributes.addClass('visually-hidden') }}>{{ title }}</h1> {% else %} <h1{{ title_attributes }}>{{ title }}</h1> {% endif %}
This is is not adding the class while the boolean is set on or off.