Customize the front page template

Last updated on
21 March 2017

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

If you want to layout your front page dramatically different from the rest of your site, you can define a whole other template just for that.

Creating a Front Page Template

Creating a front page template is rather simple. In your theme folder (sites/all/themes/), copy the page.tpl.php file from drupal core or your parent theme. Then rename it accordingly (see below). You probably won't see the results until you clear your cache; so make sure to do that.

Drupal 7
In Drupal 7, copy the page.tpl.php file and name it page--front.tpl.php.

Drupal 6
In Drupal 6, copy the page.tpl.php file and name it page-front.tpl.php

Template Suggestions

Any Drupal page can be themed specifically, using the template-suggestions process used in phptemplate theme engine. This is powerful, learn about it.

Note that using relative paths to images (or swf) directly from that page will not work to find images stored nearby in your theme directory. Placing those images in your theme directory is the correct thing to do, but you will have to rewrite your HTML to either use:
<img src="/sites/all/themes/yourtheme/images/yourimage.gif" /> (which is bad, but quick) or <img src="<?php print $directory; ?>/images/yourimage.gif" /> which is much better, if you're working on a base theme - $directory returns the current active theme path. If you're creating a subtheme, though, $directory will still return your base theme path. So, in subtheme we've to use slightly more complex construction:
<img src="<?php print $base_path . drupal_get_path('theme', 'YOURSUBTHEME_NAME'); ?>/images/yourimage.gif"/>

To do a custom front page that is mostly unique, yet merges seamlessly with Drupal, you can:

  1. Create a template file with the following naming conventionpage--front.tpl.php in your active theme directory.
  2. Paste in solid, static HTML, with appropriate file path fixes.
  3. Compare your template file with the default page.tpl.php in the theme folder and edit and needed.
  4. You can put $content in the middle, sidebars in a useful place for you to call blocks into later, and the $footer in your footer zone, etc. Try to copy as much as possible - most of it can be useful, and is the real reason for using a CMS.

Under Drupal 6, new templates may not always be recognized or used immediately. Visit the admin-themes page and submit once to refresh the themes cache the first time you add the *.tpl.php

There are also several module designed to give you advanced control of the page without too much template work, such as Panels or maybe Node Style

See the tutorials for advice on how to change the content of the front page and replace the "River of news" or the "Welcome to Drupal" with a specific page.

Help improve this page

Page status: No known problems

You can: