In a template, is it possible to get the content of a block by the block ID?
Yes take a look at this module :


  Twig Blocks


https://www.drupal.org/project/twig_blocks

After module install just call the block like this in the template :

{{ render_block('machine_name_of_your_block') }}


Or in a hook :

function hook_preprocess_page(&amp;$variables)
{

    $block = \Drupal\block\Entity\Block::load('id_block');

    $variables['myBlock'] = \Drupal::entityTypeManager()
        -&gt;getViewBuilder('block')
        -&gt;view($block);

}


Then in your twig template :

  {{ myBlock }}