0
votes

I am working on a drupal website that has a theme installed to it.

I would like to set the Front/Home page of the website to a .html.twig template I have in a custom module I am busy working on.

How would I go about doing this? I have done some googling and it likes like the answer lies somewhere with page--front.html.twig, but I am not sure where to go from here.

Inside my themeFolder/templates there are page--front.html.twig & page.html.twig

I have tried creating my own page--front.html.twig and storing it inside myModule/templates but this did not help me.

Also, how would I go about applying .html.twig templates to different regions of my website?

Any advice would be greatly appreciated

2

2 Answers

0
votes

Enable debug and check which template is using in front page. To enable the debug go to sites/default/development.services.yml

0
votes

You will need to locate core/modules/system/templates/page.html.twig file. This is a base page template that you can extend. Copy this file into your theme templates folder (Look for tpl or templates folder - it depends on the theme you are using). Rename this file to page--front.html.twig and finally flush caches for the change to take effect. This can be done by executing drush cr in your terminal or in the UI (admin/config/development/performance).

If you are planning to work on custom layout for your homepage I would suggest creating a dedicated content type (for example Landing page) and setting up your layout with the help of Paragraphs module. This would allow you to avoid hardcoding functionality in you template files.