Laravel Breadcrumbs Package

Laravel Breadcrumbs Package

Breadcrumbs are one of those things that I don’t think about until I need them, and then I feel like I recreate a system for them in my application every time.

Laravel Breadcrumbs is a package by Dave James Miller that makes adding breadcrumb navigation to your application (relatively) painless with a simple API:

// Home
Breadcrumbs::for('home', function ($trail) {
    $trail->push('Home', route('home'));
});

// Home > About
Breadcrumbs::for('about', function ($trail) {
    $trail->parent('home');
    $trail->push('About', route('about'));
});

// Home > Blog
Breadcrumbs::for('blog', function ($trail) {
    $trail->parent('home');
    $trail->push('Blog', route('blog'));
});

To render breadcrumbs, you can pick from the following templates that ship with the Laravel Breadcrumb package at the time of writing:

  • breadcrumbs::bootstrap4
  • breadcrumbs::bootstrap3
  • breadcrumbs::bootstrap2
  • breadcrumbs::bulma
  • breadcrumbs::foundation6
  • breadcrumbs::materialize
  • breadcrumbs::json-ld
  • The path to a custom view: e.g. partials.breadcrumbs

Depending on which template you need, you configure it as a published configuration in config/breadcrumbs.php:

    'view' => 'breadcrumbs::bootstrap4',

And finally you render the breadcrumbs in your view:

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

This package even supports JSON-LD structured data for SEO purposes which is really helpful:

<head>
    ...
    {{ Breadcrumbs::view('breadcrumbs::json-ld', 'category', $category) }}
    ...
</head>

Learn More

The Laravel Breadcrumb package is highly customizable and has a lot of documented options in the readme. You should check out the official GitHub repository for complete documentation and installation instructions.


Filed in: Laravel Packages


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior PHP/Laravel Developer: Your Dream Work Environment
Remote
iPhone Photography School
In-house Laravel Developer.
Gold Coast / Australia
MXstore
Laravel Developer
Oak Brook, IL
Tidal Commerce
Senior Backend Engineer
Santa Monica only
Saatchi Art
Senior Laravel Developer
San Francisco
Stitch Labs
Senior Software Developer
South Jordan, UT
Lendio
Full-Stack Developer
Paris, France
Wingly