Node object doesn't exist when not logged in I am trying to use the preprocess_page hook to add some twig variables.

All worked fine, until I logged out. When I'm logged out, the hooks $variables does not contain a node object.

Sample code:

function MYTHEME_preprocess_page(&amp;$variables) {
  $variables['hero_image'] = '';

  if (!empty($variables['node'])) {
    $node = $variables['node']; // if logged in, this is set, logged out, it's not
    // other code here...
  }

}
Maybe you should check the anonymous user permisions 
www.yourwebsite.com/admin/people/permissions/anonymous