Basic Usage

Outputting Breadcrumbs

{note} You're browsing the documentation for an old version of laravel-breadcrumbs. Consider upgrading your project to v4. Check your version with the following command:

composer show rawilk/laravel-breadcrumbs

Call Breadcrumbs::render() in the view for each page, passing it the name of the breadcrumb to use an any additional parameters.

In the page (e.g. resources/views/home.blade.php):

{!! Breadcrumbs::render('home') !!}

Or with a parameter:

{!! Breadcrumbs::render('category', $category) !!}

In the page (e.g. resources/views/home.blade.php):


    {!! Breadcrumbs::render('home') !!}

Or using the shorthand syntax:


@section('breadcrumbs', Breadcrumbs::render('home'))

And in the layout file (e.g. resources/views/layouts/master.blade.php):


In the page (e.g. resources/views/home.php):

<?php echo Breadcrumbs::render('home'); ?>

To render breadcrumbs as JSON-LD structured data (usually for SEO reasons), use Breadcrumbs::view() to render the breadcrumbs::json-ld template in addition to the normal one. For example:

        {!! Breadcrumbs::view('breadcrumbs::json-ld', 'category', $category) !!}
        {!! Breadcrumbs::render('category', $category) !!}

{note} If you use Laravel Page Speed you may need to disable the TrimUrls middleware.

To specify an image, add it to the $data parameter in push():

Breadcrumbs::for('post', function (Generator $trail, $post) {
        ->push($post->title, route('post', $post), ['image' => asset($post->image)]);

If you prefer to use Microdata or RDFa, you will need to create a custom template.

Custom Templates
Caught a mistake? Suggest an edit on GitHub