Skip to content Skip to navigation

Customize Site Offline (Maintenance) Page

Posted by: 
Topics: 

When you start to develop a site in Drupal, one of the first things you might want to do is to hide it from the public while you configure the site.

Activate the Off-line Page

In the administration interface, go to /admin/settings/site-maintenance. Set the site status to off-line and change the default off-line message.

That's all you need to do to have the front page of your site be overridden by this off-line message.

NOTE: If you find that you have logged-out of your site and do not know how to get back in, simply enter the URL for the login page:
http://your site path/?q=user/
or
http://your site path/user/

Theme the Offline Page
The default offline page has the Drupal icon in the background. You may, instead, want the off-line notice to match your theme.

  1. If you have not already done so, set your custom logo and custom icon here: admin/build/themes/settings

    This will put the files into your siteroot/files directory.

  2. Modify your theme's template.php file by adding the following code at the end of the file

  3. /**
    * Generates a site off-line message
    */

    function phptemplate_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
    drupal_set_header('Content-Type: text/html; charset=utf-8');
    drupal_set_html_head('@import "'. base_path() . drupal_get_path('module', 'system') .'/defaults.css";');
    drupal_set_html_head('@import "'. base_path() . drupal_get_path('module', 'system') .'/system.css";');
    drupal_set_html_head('@import "'. base_path() . path_to_theme().'/maintenance.css";');
    drupal_set_html_head('');
    $output = "\n";
    $output .= '';
    $output .= '';
    $output .= ' '. strip_tags(drupal_get_title()) .'';
    $output .= drupal_get_html_head();
    $output .= drupal_get_js();
    $output .= '';
    $output .= "";
    $output .= '';
    $output .= '';
    $output .= '';
    if ($messages) {
    $output .= theme('status_messages');
    }
    $output .= $content;
    $output .= "";
    $output .= "";
    $output .= "";
    return $output;
    }

  4. Create a maintenance.css file in your theme directory.