Module with block plugin not using custom template I am struggling to get my custom module template to get use by by block plugin.

I have followed the solution given at: Twig Template for a Custom Block Plugin but continually get this error:


  The website encountered an unexpected error. Please try again later.
  Twig_Error_Loader: Template
  "modules/custom/lrg_osm/templates/block--osmnhd.html.twig" is not
  defined in Twig_Loader_Chain->getCacheKey() (line 64 of
  themes/contrib/bootstrap/templates/block/block.html.twig). 
  Drupal\Core\Template\TwigEnvironment-->getTemplateClass("modules/custom/lrg_osm/templates/block--osmnhd.html.twig")
  (Line: 424)


I have tried to also fiddle the name of the twig file in various ways to not avail.

My module file structure is shown below with relevant code if anyone is able to point out the error of my ways please:



src/Plugin/Block/osmnhdblock.php

&lt;?php
declare(strict_types=1);

namespace Drupal\lrg_osm\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;

/**
 * Provides a 'OSM Block for Home development Landing page' block.
 *
 * @Block(
 *   id = "osmnhdblock",
 *   admin_label = @Translation("OSM New Homes Development (NHD) block"),
 *   category = @Translation("LRG")
 * )
 */
class OsmNhdBlock extends BlockBase implements BlockPluginInterface
{
    /**
     * {@inheritdoc}
     *
     */
    public function build()
    {
        return array(
            '#theme' =&gt; 'osmtheme',
            '#jsonDataLocations' =&gt; 'nhd some data',
            '#title' =&gt; 'nhd some title',
        );

        /*
         '#attach' =&gt; [
                'css' =&gt; '/css/openstreetmap.css',
                'js' =&gt; '/js/openstreetmap.js',
            ],
         */
    }
}


lrg_osm.module

&lt;?php
declare(strict_types=1);

function lrg_osm_theme($existing, $type, $theme, $path) {

    return array('osmtheme' =&gt;
        array(
            'variables' =&gt; array(
                'title' =&gt; null,
                'jsonDataLocations' =&gt; null
            ),
            'template' =&gt; 'block--osmnhd'
        )
    );
}


templates/block--osmnhd.html.twig

{#
/**
 * @file
 * Some description
 */
#}
&lt;div class="col-md-12 block--osmnhdmap"&gt;
    &lt;h1&gt;{{ title }}&lt;/h1&gt;
    &lt;h2&gt;{{ jsonDataLocations }}&lt;/h2&gt;
&lt;/div&gt;
The templates directory must always be a direct descendent of the module or theme root directory, in your case /modules/custom/lrg_osm/templates/ (not modules/custom/lrg_osm/src/templates/).