I added a custom block in the header of a view, and I am trying to get it to display. The block contains social media icons and links.

If I want to add a custom text area, I can use this code -

{{ view.header.area.options.content.value }}

In my kint I see this for the block I added -

      "header" => array:3 [▼
          "entity_block" => array:12 [▼
            "id" => "entity_block"
            "table" => "views"
            "field" => "entity_block"
            "relationship" => "none"
            "group_type" => "group"
            "admin_label" => ""
            "empty" => true
            "tokenize" => false
            "target" => "socialicons"
            "view_mode" => "default"
            "bypass_access" => false
            "plugin_id" => "entity"

So I tried to do {{ view.header.entity_block }} but I get an error -

Exception: Object of type Drupal\views\Plugin\views\area\Entity cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 425 of core/lib/Drupal/Core/Template/TwigExtension.php).

What can I do to display the block?

1 Answer 1


You probably are confusing {{ header }} and {{ view.header }}.

The first prints the header section including the block:


{{ header }}

The second one returns ViewExecutable::$header, an array of handler plugins you have configured in the View. You can try to extract configured string values like in the first example but in case of a block entity you probably only find the block id and you have to load and render the block yourself. It would be much easier though to print {{ header }}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.