Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Adding template suggestions for view modes and content types in Drupal 8
* Implements hook_theme_suggestions_HOOK_alter() for node.html.twig.
function MYTHEME_theme_suggestions_node_alter(array &$suggestions, array $variables) {
// Add template suggestions based on the current view mode.
$node = $variables['elements']['#node'];
$suggestions[] = 'node__' . $variables['elements']['#view_mode'];
$suggestions[] = 'node__' . $node->bundle() . '__' . $variables['elements']['#view_mode'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.