I've added a custom block (which is an image) in the HEADER section of a view. I want to show this image at the top of my page but currently it appears in content views-view.html.twig.

How can I access to this image in page.html.twig?

1 Answer 1


Take away the block from the view header and use twig_tweak module to be able to insert something like this in your twig template

{# No need to configure this block on "admin/structure/block" page. #}
<dd>{{ drupal_block('BLOCKID') }}</dd>

Or if you don't want to use an extra module add to your THEMENAME.theme

function THEMENAME_preprocess_page(&$variables) {
  $block = \Drupal\block\Entity\Block::load('BLOCKID');
  $content = \Drupal::entityTypeManager()->getViewBuilder('block')->view($block);
  $variables['my_block'] = $content;

and in your twig template just use

{{ my_block }}
  • Thank you so much. The first approach look better.
    – Sky
    Commented Feb 10, 2018 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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