How can I alter node markup from a custom module (not theme)? In a custom D8 module (not a theme or sub-theme) what is the best way to alter all nodes of a specific content type by prepending them with simple markup?
I'm trying this approach with no success ...
custom/custom.module:
&lt;?php
/**
 * @file
 * Custom module hook implementations.
 */
/**
 * Implements hook_theme().
 */
function custom_theme() {
  return [
    'custom_article_node' =&gt; [
      'template' =&gt; 'custom-article-node',
      'variables' =&gt; [],
    ],
  ];
}

custom/templates/custom-article-node.html.twig:
&lt;i&gt;This is a Custom Article node.&lt;/i&gt;
{{ content }}

I'm not sure how to pass the node to the template, or to test what content type it is ... and I'm not sure if this theme hook is even executing.
(I know how to override templates in the theme layer, but in this case I need to do it in a custom module.)
This did the trick:
custom.module:
&lt;?php

/**
 * @file
 * Custom module hook implementations.
 */

/**
 * Implements hook_theme().
 */
function custom_theme() {
  return [
    'node__custom_article' =&gt; [
      'template' =&gt; 'node--custom-article',
      'base hook' =&gt; 'node',
    ],
  ];
}

Credit where it's due:
https://www.drupal.org/forum/support/module-development-and-code-questions/2015-06-03/drupal-8-override-template-with#comment-12461953