Skip to content

[6.x] Fix nav:breadcrumbs including home when include_home is false - #15244

Open
wakqasahmed wants to merge 2 commits into
statamic:6.xfrom
wakqasahmed:fix/issue-12584-breadcrumbs-exclude-home
Open

[6.x] Fix nav:breadcrumbs including home when include_home is false#15244
wakqasahmed wants to merge 2 commits into
statamic:6.xfrom
wakqasahmed:fix/issue-12584-breadcrumbs-exclude-home

Conversation

@wakqasahmed

Copy link
Copy Markdown

What

{{ nav:breadcrumbs include_home="false" }} still showed the home entry when the current page resolved to a root-adjacent segment.

Why

In breadcrumbs(), when include_home is false, array_shift($segments) drops the leading / marker. When the current URL is the site root (/), the remaining segments array is left containing a single empty string. That empty string is then imploded and passed through URL::tidy(), which normalizes an empty string back to /, and Data::findByUri('/') resolves that to the Home entry — reintroducing the crumb the caller explicitly asked to exclude.

Fix

After shifting off the home segment, filter out any resulting empty segments before building URIs, so an empty/root segment is never fed into tidy()/findByUri().

Test plan

  • Added tests/Tags/NavBreadcrumbsTest.php covering:
    • default include_home behavior (home included)
    • include_home="false" on a nested page (home excluded, other crumbs intact)
    • include_home="false" on a top-level page
    • include_home="false" while viewing the home page itself (no breadcrumbs at all, previously incorrectly returned the home crumb)

Fixes #12584

…ic#12584)

When include_home is false, array_shift() removed the leading home
segment, but a root URL left a trailing empty segment that URL::tidy()
normalized back to '/', which then resolved to the Home entry.

Filter out empty segments after the shift so they never reach
tidy()/findByUri().
@duncanmcclean duncanmcclean changed the title Fix nav:breadcrumbs including home when include_home is false [6.x] Fix nav:breadcrumbs including home when include_home is false Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nav:breadcrumbs includes home even though it shouldn't

2 participants