Get is_front frontpage variable in node.html.twig twig file

 

/**
 * Implements hook_preprocess_node().
 */
function MYTHEME_preprocess_node(&$variables)
{
  $variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage();
}

No, in my node--page.html.twig I can use:

{% if is_front %}
// Do something
{% endif %}

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!