Changing the ‘Home’ breadcrumb in Drupal 6

Here’s something I was googling last week – How do you change the text of Drupal’s ‘Home’ breadcrumb to something else? Well, it turns out that a small mod to your theme may be required…


While using Drupal 6 to develop a web application we ran into a little snag with Drupal’s breadcrumbs, the app is to integrate in with our client’s existing web site, it will look and feel the same and the visitor should not really know that it is separate from the main website (which is not implemented with drupal).  With drupal this was all easy enough to achieve, but we hit a speed bump when it came to the web app’s breadcrumbs.  Breadcrumb navigation is very important for the new web application, but Drupal always calls the first breadcrumb ‘Home’ – this was a problem as ‘Home’ did not refer to the larger web site’s home page as would be expected, but instead to the first page of the web application.


So how do we change the ‘Home’ breadcrumb text to something else, say the title of our web application?  It turns out that there’s no easy way to do this through settings, but thanks to this thread we can see that it is possible via a small change to the active theme. The modification hooks into phptemplate_breadcrumb(), it removes the existing primary breadcrimb (‘Home’) and then inserts a replacement with the new text.


So to make the change, edit your theme’s template.php file, and search for the function called:


[code lang="php"]phptemplate_breadcrumb() [/code]

rename it to:

[code lang="php"]original_phptemplate_breadcrumb() [/code]

Then paste in the following, changing ‘New Home Text’ to what ever you want your ‘Home’ breadcrumb to be called.

[code lang="php"]
function phptemplate_breadcrumb($breadcrumb)
  if (!empty($breadcrumb))
    // remove the exisitng Home link
    $old_home_link = array_shift($breadcrumb);
    // insert the new link
                   l(t('New Home Text'), ''));
    // Get the original function to
    // output the breadcrumb
    return original_phptemplate_breadcrumb($breadcrumb);

With this theme modification in place the breadcrumbs should display with the new text in place, bit of a pain but at least it’s do-able!



Hats off to gwen for the tip & code!

1 reply
  1. Gareth S Price
    Gareth S Price says:

    Here’s what I ended up with, based on the code above:

    function phptemplate_breadcrumb($breadcrumb) {
    if(!empty($breadcrumb)) {
    $breadcrumb[0] = l(variable_get('site_name', 'Home'), '');
    return theme_breadcrumb($breadcrumb);

Comments are closed.