Print block in page.html.twig in D8

Here is the steps
Step 1: Open your_theme.theme file
Step 2: Copy and paste below code in your theme file
function yourtheme_preprocess(&$variables, $hook)
{
$variables['base_path'] = base_path();
$block = DrupalblockEntityBlock::load('<strong>yourtheme_search</strong>');
$block_content = Drupal::entityTypeManager()
->getViewBuilder('block')
->view($block);
<em> $variables['youblockname'] </em>= $block_content;
}
Change yourtheme_searchwith your block name
Step 3: Use below code in your page.html.twing file
{{ youblockname }}

Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.