I'm attempting to perform an action in a preprocess node hook inside my .theme file, but I can't seem to get it to fire.
Here's the content of my customtheme.theme file
<?php
function mytheme_preprocess_page(&$variables){
$menu = \Drupal\block\Entity\Block::load('custom_main_menu');
$variables['main_menu'] = \Drupal::entityTypeManager()
->getViewBuilder('block')
->view($menu);
}
function mytheme_preprocess_node(&$variables){
die('Test');
}
Everytime I load a node, even though I have a die() statement in my mytheme_preprocess_node function it never fires, and the page loads just fine. I'm making sure that I'm loading pages that are nodes. Such as basic pages, and other custom content types. What's odd is that the mytheme_preprocess_page function does fire. It's able to load the main_menu variable inside the page.html.twig template just fine. I also made sure I was clearing the cache.
Why would a preprocess_page hook function fire but not a preprocess_node function.