How to create a custom home page template in Drupal 7

We were working on a Drupal 7 site this week, and came across a need to overwrite the default page template for Drupal’s homepage.

We had already set a node as the homepage content (rather than the homepage being used for the site’s latest content), as it was more of a brochure/ecommerce-style website (we used Drupal Commerce – see our write-up of Magento vs Drupal Commerce instigated by that).

So, to overwrite Drupal 7’s homepage template, you need to create a file called page–front.tpl.php in your theme’s directory. Note the double hyphens between the words page and front there; this is a slight change from the way it was done in Drupal 6, for instance. You can no longer use page-home.tpl.php or page-front.tpl.php to overwrite Drupal’s homepage layout.

An alternate way to overwrite Drupal’s homepage template

Generally, the easiest way to start customising your theme’s homepage template is to copy and paste the contents of your theme’s page.tpl.php template in to the newly created page–front.tpl.php. Of course, if you know the node ID of the page you’re using as Drupal’s homepage, you could use:


or similar, assuming your homepage’s node ID is 4, but this is less bullet proof than using the page–front.tpl.php format.

Still need help with your Drupal theme? We can help you!