Community Documentation

Totally customize the LOOK of your front page

Last updated June 29, 2011. Created by dman on October 6, 2008.
Edited by bukem, ashmiler, SLIU, kay_v. Log in to edit this page.

If you want to lay out your front page dramatically differently from the rest of your site, you can define a whole other template just for that.
This could be handy if you have:

  • A highly graphic front page.
  • A working mock-up from a designer that can't be changed much.
  • A flash blob as a landing page.
  • A splash screen, or any other special requirement.

... and working that into a generic Drupal theme template is just not practical.

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

At its simplest, you can:

  1. Create a page called page-front.tpl.php in your active theme directory.
  2. Paste in solid, static HTML, with appropriate file path fixes.
  3. Done.

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 - $directory always returns the current active theme path)

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

  1. Create a file called page-front.tpl.php in your active theme directory.
  2. Paste in solid, static HTML, with appropriate file path fixes.
  3. Compare your page with the themes normal page.tpl.php and copy as much of the code tags as is logical into your new file in appropriate places.
  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.

Comments

Custom front page in Drupal 7

It would be helpful to add that in Drupal 7 the custom template must be named page--front.tpl.php, with two hyphens instead of one.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 5.x, Drupal 6.x

Theming Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.