Share icon

If you know how to make a content type template in drupal 7 then you can easily understand in drupal 8, Here there is not much change except that the template is in twig format. 

For creating the content type template in drupal 8 you have to do two things :

1) Add this code in your mytheme.theme file in your working theme folder :-

function hook_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  if ($node = \Drupal::routeMatch()->getParameter('node')) {
    $suggestions[] = 'page__' . $node->bundle();
  }
}

above code helps to recognized drupal 8 to work with specific content type template.

(Note: replace hook with your theme name)

2) Now copy page.html.twig and rename it wit your content type name like

e.g  page--article.html.twig

 

clear the cache and Done.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.