hook_page_alter in Drupal 8 I am trying to append a twig template on every page .
In drupal 7, we basically append it using hook_page_alter 

      function hook_page_alter(&amp;$page) { 
      $page['page_bottom']['devel']= array( 
            '#type' =&gt; 'markup', 
            '#markup' =&gt; '&lt;div style="clear:both;"&gt;' . theme('TEST') . '&lt;/div&gt;', );  //add test template on every page at bottom position
 } 


but in drupal 8 there is no hook_page_alter i think. 

How to do this??
hook_page_alter in Drupal 8:

According to the change record Added hook_page_attachments(_alter)() and removed hook_page_build/alter() you should use hook_page_bottom:

function hook_page_bottom(array &amp;$page_bottom) {
  $page_bottom['mymodule'] = ['#markup' =&gt; 'This is the bottom.'];
}


You have another issue, theme() is no longer available. But this is another question as it is unclear what you are trying to do with it. Probably you should use the template in a render array $page_bottom['mymodule'] = ['#theme' =&gt; 'TEST'];.

In D8 all page elements are in blocks now. The best approach would be to provide the extra content in a custom block and place it in the block layout in the bottom of the page. See comment from @Kevin.