How to move block from a region inside of hook_preprocess_node? I have added mycustomblock to the header region in our settings (/admin/structure/block). We are using the standard content block and displaying that in the Content region, which is displayed below the Header region. 

For just our Basic Page content type, we would like to move the mycustomblock to display below another field. We tried using the mymodule_preprocess_node hook to move the block below one of the fields (i.e. field_categories). However, we don't know how to move the block. 

How would we move the block inside the hook_preprocess_node?

Setup:

Basic Page content type


Title
Categories (field_categories)
Tags (field_tags)
Image (field_image)


node--page--full.html.twig

{{ label }}
{{ content.field_image }}

/* I want to display the block here, using some variable */
{{ mycustomblock_variable }}

{{ content.field_categories }}
{{ content.field_tags }}


Regions (order displayed: top down)


header
content
footer


We tried the following but it didn't work

function mymodule_preprocess_node($variables) {
  $node = $variables['elements']['#node'];

  if($node-&gt;bundle() == 'page') {
    $block_entity = Drupal\block_content\Entity\BlockContent::load(123456);// BLOCK_ID
    $block_view = \Drupal::entityTypeManager()-&gt;getViewBuilder('block_content')-&gt;view($block_entity, 'mycustomblock');
    $variables['mycustomblock_variable'] = $block_view;
  }
}
I think you should send render of the block not an array of block entity.
View Method return an array.

Try with renderer service like the following:

/**
 * Implements hook__preprocess_HOOK().
 */
function mymodule_preprocess_node(&amp;$variables) {
  $node = $variables['elements']['#node'];
  if ($node-&gt;bundle() == 'page') {
    $block_entity = Drupal\block_content\Entity\BlockContent::load(12345);//BLOCK_ID
    $block_view = \Drupal::entityTypeManager()
      -&gt;getViewBuilder('block_content')
     // Change here default by your block view mode
      -&gt;view($block_entity, 'default');
    $variables['mycustomblock_variable'] =\Drupal::service('renderer')-&gt;renderRoot($block_view);
  }
}