How to display a block in twig (D8) I read the other similar questions, but it didn't work.

I created a block in a region and I want to display that same block on my custom page (inside the twig).

I'm using this code to load the block:

$block = \Drupal::entityTypeManager()-&gt;getStorage('block')-&gt;load('block_id');
$block_content =  \Drupal::entityTypeManager()-&gt;getViewBuilder('block')-&gt;view($block);


and I'm trying to build it like this:

$build['page'] = array(
      '#type' =&gt; 'inline_template',
      '#template' =&gt; $template,
      '#form' =&gt; $block_content,
);
return $build;


My twig file is like this:

&lt;section&gt;
  &lt;tbody&gt;
    &lt;div&gt;{{ form }}&lt;/div&gt;
  &lt;/tbody&gt;
&lt;/section&gt;


But nothing is displayed...
What am I doing wrong?

Thanks in advance.
To make the form variable available in the Twig template you need to supply a context like follows.

$build['page'] = [
  '#type' =&gt; 'inline_template',
  '#template' =&gt; $template,
  '#context' =&gt; ['form' =&gt; $block_content],
];


Generally, I would recommend using custom #theme hook instead of an inline template.

Another way to render block within a template is using Twig Tweak module.

{{ drupal_entity('block', 'block_id') }}