Why is my twig variable not working inside my block twig? I have a field I'm pulling into a block twig template block--block-03.html.twig, and it outputs fine by itself (= {{content.field_content_side}}). But when I put it inside of a conditional it is not working.

Here's my code to illustrate what I mean:

&lt;h1&gt;{{ content.field_content_side }}&lt;/h1&gt;
&lt;h2&gt;{% if content.field_content_side == 'left' %}col-sm-push-7{% else %}wtf{% endif %}&lt;/h2&gt;


The output is here:



Why is it recognizing the twig variable correctly as left (= 1st line of my code), but in the conditional it is saying it's not left (= 2nd line of my code)?
Because the field is being rendered, which is different than evaluating its value. content.field_content_side is a render array which holds a lot more than just 'value'.

Try:

{% if node.field_content_side.value == 'left' %}


To get this in a block, you would add this to mytheme.theme:

/**
 * Implements hook_preprocess_block().
 * @param $variables
 */
function mytheme_preprocess_block(&amp;$variables) {
  if (isset($variables['elements']['content']['#block_content'])) {
    $variables['block_content'] = $variables['elements']['content']['#block_content'];
  }
}


Then:

{% if block_content.field_content_side.value == 'left' %}