I am developing new website in D7 and I have installed bootstrap theme on the of it.

So, now I want to create home page/front page for my website and for that I have created a basic page, but I am not able to add CSS and JS in that basic page.

What approach should I use to create a front page in Drupal 7?


4 Answers 4


Depends on what your needs are. One approach is to go with panels. It gives you a nice UI for including blocks, nodes and other pieces of content.

The Panels module allows a site administrator to create customized layouts for multiple uses. At its core it is a drag and drop content manager that lets you visually design a layout and place content within that layout. Integration with other systems allows you to create nodes that use this, landing pages that use this, and even override system pages such as taxonomy and the node page so that you can customize the layout of your site with very fine grained permissions.

The second approach, which has become my preferable, is to create your frontpage as a node and add the necessary views or blocks on it.

Regardless of your approach, if you are in need to add js and css files in the frontpage you can add the following in you template.php file(source):

function yourtheme_preprocess_page(&$vars) {
  if(drupal_is_front_page()) {
    drupal_add_js(drupal_get_path('theme', 'yourtheme') . '/js/your-front-script.js');
    drupal_add_css(drupal_get_path('module', 'example') . '/example.css');

There are two option:

  1. Use a different template for the front page you have to name your template page--front.tpl.php and clear the theme registry. Please check Theming Guide for more details.

  2. There's also the Front Page module: http://drupal.org/project/front


If you look at the frontpage's source code you'll find something like this:

<body style="padding-top: 65px;" class="html front logged-in no-sidebars page-node toolbar toolbar-drawer i18n-es disqus-processed">

so you may want to create a css rule that applies to .front class.


create page--front.tpl.php template file inside your theme tpl folder.

It will work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.