Breadcrumb Preprocess from Module I'm currently using the preprocess_breadcrumb hook in my .theme file to customize the output of my breadcrumbs like so:

function mytheme_preprocess_breadcrumb(&amp;$variables){
    $node = \Drupal::routeMatch()-&gt;getParameter('node');
    $current_path = \Drupal::service('path.current')-&gt;getPath();
    $result = \Drupal::service('path.alias_manager')-&gt;getAliasByPath($current_path);
    $crumbs = explode("/", $result);
    if($node){
        $variables['current_title'] = $node-&gt;getTitle();
        $variables['crumbs'] = $crumbs;
    }
}


I then use breadcrumb.html.twig to use these new variables like so

    &lt;nav role="navigation" aria-labelledby="system-breadcrumb"&gt;
    &lt;h2 id="system-breadcrumb" class="visually-hidden"&gt;{{ 'You are here'|t }}&lt;/h2&gt;
    &lt;ul class="breadcrumbs"&gt;
        {% for crumb in crumbs %} 
            {% if loop.first %}
        &lt;li&gt;&lt;a href="./"&gt;Home&lt;/a&gt;&lt;/li&gt;
        {% elseif loop.last %}
        &lt;li class="current"&gt;&lt;a href="#"&gt;{{ current_title }}&lt;/a&gt;&lt;/li&gt; 
        {% elseif crumb == 'node' %}
        {% else %}
        &lt;li&gt; &lt;a href="../{{ crumb }}"&gt;{{ crumb }}&lt;/a&gt;&lt;/li&gt;
        {% endif %}
        {% endfor %}
    &lt;/ul&gt;
&lt;/nav&gt;
{% endif %}


However I'd like it more if all this was encapsulated in a module. In mymodule.module file I have

function mymodule_preprocess_breadcrumb(&amp;$variables){
$node = \Drupal::routeMatch()-&gt;getParameter('node');
$current_path = \Drupal::service('path.current')-&gt;getPath();
$result = \Drupal::service('path.alias_manager')-&gt;getAliasByPath($current_path);
$crumbs = explode("/", $result);
if($node){
    $variables['current_title'] = $node-&gt;getTitle();
    $variables['crumbs'] = $crumbs;
}


}

But this function never fires. Is there a way to use the preprocess_breadcrumb hook from a module?
Preprocess hooks work in themes and modules. It doesn't matter where you put it, the only difference is, that modules have higher priority.

What you have to do is to work on caching. Because of the variables you put in,  you need a cache context on url.path, 

$variables['#cache']['contexts'][] = 'url.path';


That doesn't make a difference for the first run after clearing the cache, but makes sure that the hook is run for every new path.