Drupal 8/9 how to add suggestions of page templates for content types

In Drupal 8 and Drupal 9 add suggestions of page templates for the different content types by using the hook_theme_suggestions_page_alter() function in .theme file.

For example, if you want to create page template for specific content type like page--[content-type].html.twig. For article content type naming convention will be page--article.html.twig, the Basic page content type naming convention will be page--page.html.twig and the car content type naming convention will be page--car.html.twig.
copy-icon

Comments

Authors

Read Next