4.6.x bootstrap.inc drupal_set_title($title = NULL)
4.7.x path.inc drupal_set_title($title = NULL)
5.x path.inc drupal_set_title($title = NULL)
6.x path.inc drupal_set_title($title = NULL)
7.x bootstrap.inc drupal_set_title($title = NULL, $output = CHECK_PLAIN)

Sets the title of the current page.

The title is displayed on the page and in the title bar.


$title: Optional string value to assign to the page title; or if set to NULL (default), leaves the current title unchanged.

$output: Optional flag - normally should be left as CHECK_PLAIN. Only set to PASS_THROUGH if you have already removed any possibly dangerous code from $title using a function like check_plain() or filter_xss(). With this flag the string will be passed through unchanged.

Return value

The updated title of the current page.

65 calls to drupal_set_title()
aggregator_page_source in modules/aggregator/aggregator.pages.inc
Page callback: Displays all the items captured from the particular feed.
authorize_access_denied_page in ./authorize.php
Renders a 403 access denied page for authorize.php.
authorize_run_operation in includes/authorize.inc
Runs the operation specified in $_SESSION['authorize_operation'].
block_admin_configure in modules/block/block.admin.inc
Form constructor for the block configuration form.
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.

... See full list


includes/bootstrap.inc, line 2153
Functions that need to be loaded on every Drupal request.


function drupal_set_title($title = NULL, $output = CHECK_PLAIN) {
  $stored_title =& drupal_static(__FUNCTION__);
  if (isset($title)) {
    $stored_title = $output == PASS_THROUGH ? $title : check_plain($title);
  return $stored_title;


nerdoc’s picture

I tried in mytheme_preprocess_html() and mytheme_preprocess_page(), and nothing changed...
function MYTHEME_preprocess_page(&$vars){
DO I have to do that earlier in bootstrap?

nerdoc’s picture

nevermind, It worked. My fault. Delete this posting if possible.

Sirgey’s picture

drupal_set_title('Text') does not work in MYTHEME_preprocess_html but it works in MYTHEME_preprocess_page (at least in my case).
not an issue, just a little helper.

Devendra Mishra’s picture

In my case, for some reason drupal_set_title did not worked in MYTHEME_preprocess_page so I have tried MYTHEME_preprocess_html and it is working.

  function MYTHEME_preprocess_html(&$vars) {
    $vars['head_title'] = $title . ' | ' . variable_get('site_name');