Twig template not rendering new field variable I created a new field for a custom block type and have already exported necessary yml files and updated the yml for different view modes.
However, when I make a reference to the new field using the correct field_machine_name, it doesn't recognize it.
This new field is a checkbox, that when enabled, hides the h1 header of the page, but is still visible for screen readers.
sample code:
{% set hide_header_title = content.field_hide_header_title|render|striptags|trim %}

 {% if hide_header_title == 1 %}
    {% set hide_header_title = &quot;show-for-sr&quot; %}
  {% else %}
    {% set hide_header_title = &quot;block&quot; %}
  {% endif %}

With the code above, I'm only getting to the else statement.
@4k4, thanks for sharing the link. I was able to retrieve the value
this way: content.field_hide_header_title[0]

content.field_myfield[0] still gets the rendered output, now of the first field item. It's not a good idea to use it for programming, because the output can be formatted in different ways and is translatable. You don't want to adjust the code anytime this is changing.
For programming if/else code better use the block content object.
content['#block_content'].field_myfield.value
This is a similar question for a node field: Boolean field inside node twig renders ok but does not work in if statement