I am newbie in Drupal. Using some articles, I have created a child theme of Bartik in Drupal 8 but I do not know how to override default template files. Can anyone help me to understand the child theme structure in Drupal 8?
1 Answer
In your child theme's folder create a subfolder called "templates". In this folder you should store your own templates. Just copy the system's (or parent theme's) template to your folder and modify it.
Further on, you can create more special templates, i.e. not only node.html.twig but also node--blog.html.twig.
Finally, switch on twig debugging, then you will get comments in your html like this:
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--bootasde-branding.html.twig
x block--system-branding-block.html.twig
* block--system.html.twig
* block.html.twig
-->
<!-- BEGIN OUTPUT from 'themes/bootstrap/templates/block/block--system-branding-block.html.twig' -->
Then you always know which template was finally taken.
-
Fine intro for twig debugging is this: drupalize.me/blog/201405/lets-debug-twig-drupal-8 Commented Jul 7, 2016 at 11:25
-
Hello @rainer thank you for your help. I have created the structure : themes/custom/my_theme/templates and copied page.html.twig from Bartik's template folder. But still my new file is not coming. Data is displaying from Bartik's file only. I have also cleared the cache. Commented Jul 7, 2016 at 11:56
-
-
-