Basic Usage

Custom Templates

{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

To customize the HTML, create your own view file (e.g. resources/views/partials/breadcrumbs.blade.php), like this:

@if (count($breadcrumbs))

    <ol class="breadcrumbs">
        @foreach ($breadcrumbs as $breadcrumb)

            @if ($breadcrumb->url && ! $loop->last)
                <li class="breadcrumb-item">
                    <a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a>
                </li>
            @else
                <li class="breadcrumb-item active">{{ $breadcrumb->title }}</li>
            @endif

        @endforeach
    </ol>

@endif

{tip} See the views/ directory for the built-in templates.

The view will receive an object called $breadcrumbs.

Each breadcrumb is an object with the following keys:

  • title - The breadcrumb title
  • url - The breadcrumb URL, or null if none was given
  • Any additional keys for each item in $data (see Custom Data)

When you create a custom view, you need to update the config/breadcrumbs.php file with the custom view name:

'view' => 'partials.breadcrumbs', #--> resources/views/partials/breadcrumbs.blade.php

Instead of creating your own custom view, you may choose to override one the package's pre-defined templates. You can do so by publishing the views:

php artisan vendor:publish --provider="Rawilk\Breadcrumbs\BreadcrumbsServiceProvider" --tag="views"

This will publish the views to resources/views/vendor/breadcrumbs. From there, you can modify the views to fit your needs.

Previous
Defining Breadcrumbs
Caught a mistake? Suggest an edit on GitHub