Render custom block using block.html.twig template I'm attempting to render a custom content block programmatically (created through the Custom Block Library UI) and I would like the block to render using block.html.twig as it would if I were to place it in a theme region. I have the block placed in a disabled region and I can get the block body field to render programmatically, but it is not wrapped in the usual block template and does not include the block title. I'm using the code to render a "content block" from the accepted answer here: How can I programmatically display a block?

$bid = ??? // Get the block id through config, SQL or some other means
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()-&gt;
getViewBuilder('block_content')-&gt;view($block);
return $render;


As I understand it, I need to render the instance of the custom block that I have placed inside the disabled region, so I would expect that I have to use the machine name of that instance. I've done a lot of searching and come up with nothing. It's strange that nobody else seems to want to render the block with the title in the block.html.twig template.
BlockContent is the only entity in Drupal not having a template of its own. So you have to wrap it in a template yourself:

$block = \Drupal\block_content\Entity\BlockContent::load($bid);
if ($block) {
  $content = \Drupal::entityTypeManager()-&gt;getViewBuilder('block_content')-&gt;view($block);
  $build = [
    '#theme' =&gt; 'block',
    '#attributes' =&gt; [],
    '#configuration' =&gt; ['label' =&gt; 'My Block', 'label_display' =&gt; 'visible'],
    '#base_plugin_id' =&gt; 'block_content',
    '#plugin_id' =&gt; 'block_content:' . $block-&gt;uuid(),
    '#derivative_plugin_id' =&gt; $block-&gt;uuid(),
    '#id' =&gt; $block-&gt;id(),
    'content' =&gt; $content,
  ];
  return $build;
}