0

What is Drupal 8 file pattern name for a specified content type?

Suppose I have a Movie content type. What is the pattern name for its page? Is it page--node--movie.html.twig?

2

This is what your looking for.

The Drupal 8 code is the following one.

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function THEMENAME_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  if ($node = \Drupal::routeMatch()->getParameter('node')) {
    $suggestions[] = 'page__' . $node->getType();
  }
  return $suggestions;
}
  • vote up. I agree with you, it work – Yusef Mohamadi Jun 9 '16 at 12:51
1

Quoting from the same page as ssibal:

Nodes

Pattern: node--[type|nodeid]--[viewmode].html.twig

Base template: node.html.twig (base location: core/modules/node/templates/node.html.twig)

Theme hook suggestions are made based on these factors, listed from the most specific template to the least. Drupal will use the most specific template it finds:

  1. node--nodeid--viewmode.html.twig
  2. node--nodeid.html.twig
  3. node--type--viewmode.html.twig
  4. node--type.html.twig
  5. node--viewmode.html.twig
  6. node.html.twig

Note that underscores in a content type's machine name are replaced by hyphens.

See the node.html.twig API documentation.

So for your content type it should be node--movie.html.twig

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.