Make variables created in preprocess_page hook available to content type templates I'm attempting to render a block plugin programmatically in a content type template. I understand how to render the block programmatically in a page template. like so

mytheme.theme

function mytheme_preprocess_page(&amp;$variables){
    $myblock = \Drupal::service('plugin.manager.block')-&gt;createInstance('myblockid',[]);
    $variables['myblock'] = $myblock-&gt;build();


page.html.twig

&lt;div class="my block"&gt;
{{ myblock }}
&lt;/div&gt;


However in

node--contenttype.html.twig

&lt;div class="my block"&gt;
{{ myblock }}
&lt;/div&gt;


Produces nothing. Is there another hook I should be using? Or is there a better way to do this entirely?
I was able to accomplish this by placing the code into the preprocess node hook instead of the preprocess page. Like so

mytheme.theme

function mytheme_preprocess_node(&amp;$variables){
    $myblock = \Drupal::service('plugin.manager.block')-&gt;createInstance('myblockid',[]);
    $variables['myblock'] = $myblock-&gt;build();