I am trying to include Structured Data in my breadcrumbs. The google validator throws an error on my final breadcrumb. When I remove class="active" from the code in the code validator window the code passes without error.

I used the theme_breadcrumb hook to add the Structured Data Markup to the breadcrumbs, but there is no mention of the css active class.

function MYTHEME_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];
    $breadcrumb = substr_replace($breadcrumb, 'http://mywebsiteexample.com/', 9, 1); 
    $rich_snippet = 'rel="v:url" property="v:title" ';
    $breadcrumb = substr_replace($breadcrumb, $rich_snippet, 3, 0); 
    if (!empty($breadcrumb)) {
        $breadcrumb[] = '<a rel="v:url" property="v:title" href="'.current_path().'" >'.drupal_get_title().'</a>';
        //Added this line  to avoid displaying node title twice
        unset($breadcrumb[count($breadcrumb) - 1]);
        $output = '<span class="element-invisible">' . t('You are here') . '</span>'; 
        $output .= '<div class="breadcrumb" xmlns:v="http://rdf.data-vocabulary.org/#"><span typeof="v:Breadcrumb">' . implode(' » </span><span typeof="v:Breadcrumb">', $breadcrumb) . '</span></div>'; 
        return $output; 

Is there another hook I can use to remove the active class exclusively for breadcrumbs? Ideally I would like to do it without inserting Javascript into any templates.

2 Answers 2


The active class is added by the l() function:

  // Append active class.
  if (($path == $_GET ['q'] || ($path == '<front>' && drupal_is_front_page())) && 
    (empty($options ['language']) || $options ['language']->language == $language_url->language)) {
    $options ['attributes']['class'][] = 'active';

It may be difficult to override this behavior. In your code replacing theme_breadcrumb it seems like you've hit upon this problem since you are not using the l function. You could loop over the values in $variables['breadcrumb'] and run a str_replace to get rid of the active class.

  • Thank you. This idea worked. I wrote a for loop that removed the active class. Unfortunately google is still throwing an error for the Structured Data, but that is a separate issue. Thanks again for your response!
    – stodd42
    Commented Sep 1, 2015 at 14:27

Why not use jQuery .removeclass() on document load so that it removes 'active' from breadcrumb for each page.

More information here.

jQuery remove class

  • Ideally I would like to do it without having to add Javascript to the page, but I might have to end up doing that.
    – stodd42
    Commented Aug 27, 2015 at 19:00

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.