19

In Drupal 6 the entire page data was stored in page.tpl.php. Now, with Drupal 7, only the content that appears in between <body> and </body>. So how do you edit the HEAD info? Is it still stored in a .tpl.php file? Where? If not, how do you do it?

migrated from stackoverflow.com Aug 1 '11 at 5:36

This question came from our site for professional and enthusiast programmers.

21

If the theme you use does not provide the file for the header, it means that Drupal is using the default one, which is now provided by a module called "system". The file is called html.tpl.php

Just copy this file into your theme, and edit it.

11

You need to copy default html.tpl.php from system module directory.

Or you can using function drupal_add_html_head to override or add new head tag.

// First, we must set up an array
$element = array(
  '#tag' => 'link', // The #tag is the html tag - <link />
  '#attributes' => array( // Set up an array of attributes inside the tag
    'href' => 'http://fonts.googleapis.com/css?family=Cardo&subset=latin',
    'rel' => 'stylesheet',
    'type' => 'text/css',
  ),
);
drupal_add_html_head($element, 'google_font_cardo');
4

If you want to change the head tag, you will need to use html.tpl.php

0

Copying html.tpl.php to your custom theme from the systems module will solve this issue. If you want to have the / tags in each of your custom .tpl files, you can just have only the following in your html.tpl.php file.

<?php print $page; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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