Laravel Voyager面包屑子域名问题:Http与URL分块显示异常
Hey, I've run into this exact weird breadcrumb issue with Laravel Voyager before—having 'Http' split out as its own separate breadcrumb block is super annoying. Let's walk through some common fixes and troubleshooting steps:
1. Check Model's getRouteKeyName Method
More often than not, this happens when your model has a misconfigured route key. If you've overridden getRouteKeyName() in your model, a wrong return value can throw off Voyager's breadcrumb parsing logic, causing it to split the URL protocol into a separate item.
Double-check your model file for something like this:
// Bad example: returning an incorrect field public function getRouteKeyName() { return 'invalid_field'; }
Make sure it returns a valid field tied to your resource—usually id or slug:
public function getRouteKeyName() { return 'slug'; // or 'id' if you're using numeric IDs }
2. Reset Voyager Menu & Clear Caches
Voyager's breadcrumbs are often linked to your backend menu configurations. If you recently edited a menu item's URL or route association, a typo or invalid setup could cause this parsing error.
- Head to your Voyager admin panel → Menus, find the problematic menu item, and verify its
URLorRoutesetting. Ensure there's no duplicatehttp://or malformed path here. - Clear all Laravel caches to rule out stale configs:
php artisan cache:clear php artisan route:clear php artisan config:clear
3. Customize the Breadcrumb View
If the default logic is still misbehaving, you can override Voyager's breadcrumb view to fix the parsing manually.
First, publish Voyager's view files to your project:
php artisan vendor:publish --tag=voyager-views
Then open resources/views/vendor/voyager/partials/breadcrumb.blade.php. Look for the loop that renders breadcrumb items—you can add logic to check if an item's text is just 'Http' and merge it with the next item, or clean up the URL parsing to ensure the full path is treated as a single breadcrumb entry.
4. Verify Route Naming & Parameters
Misnamed routes or incorrect parameter setups can also break Voyager's breadcrumb generation. Make sure your custom routes have proper names, and that they're linked correctly in Voyager's menu.
For example, a valid resource route should look like this:
Route::get('your-resource/{slug}', [YourResourceController::class, 'show'])->name('your-resource.show');
In Voyager's menu config, use the route name (instead of a raw URL) for the menu item—this helps Voyager correctly map the resource to the breadcrumb.
内容的提问来源于stack exchange,提问作者Noury

