How do I change the Drupal 8 frontpage template, so it doesn't use the regular page.html.twig template?
Enable twig_debug
and you will see HTML comments surrounding the output that tell you what template suggestions are available. In this case you will get output like:
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'page' -->
<!-- FILE NAME SUGGESTIONS:
* page--front.html.twig
* page--node.html.twig
x page.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/page.html.twig' -->
Naming your template page--front.html.twig will use that template for only the homepage.
-
how does this work with subfolders? E.g. having a folder
page
in mytemplates
directory. – ferdynator Sep 11 '15 at 10:51 -
@ferdynator it works just fine, you can add subfolders to organize your templates. – Cottser Sep 16 '15 at 19:32
-
1This won't be picked up until you clear your caches, of course (said the newbie)! – Deborah Nov 23 '16 at 8:52
views-view--frontpage.html.twig
file. Following that patterns, it's possible that the the correct template name would befrontpage.html.twig
. You might want to try. Other templates in core are named with a - separating their name frompage
, so perhapsfront-page.html.twig
? – Letharion Nov 7 '14 at 8:37