Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, I'm not sure if this is a core issue or a theme issue, but when you visit a page like anonymous user (after cache rebuild) where breadcrumb must not display any links, it's disappear from all pages.
This issue is not about that (and it's not a duplicate): https://www.drupal.org/node/2722093
We can avoid this issue excluding breadcrumbs-block from pages where breadcrumbs does not have any links.
Thanks.
Comments
Comment #2
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedComment #3
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedComment #4
markhalliwellI'm confused. The version for this issue is 7.x-3.13, but you also reference an 8.x issue and say "breadcrumbs-block" (which implies 8.x).
What exactly is the issue here?
Comment #5
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedComment #6
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedSorry, it's 8.x-3.3.
Comment #7
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedComment #8
Jill LI'm also experiencing this after upgrading to Drupal 8.3.2
Comment #9
markhalliwell@ion.macaria, you still really haven't given much information. Some clear steps to reproduce would be helpful here.
Comment #10
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedSorry @markcarver, i thought unclear was only version.
This is an example by steps:
1. Install Drupal version 8.3.1 and Bootstrap 8.x-3.2 - 8.x-3.3
2. Create a less subtheme from Bootstrap
3. Go to /admin/appearance/settings/--our-subtheme--
4. Bootstrap Settings -> Breadcrumbs -> Activate --Breadcrumb visibility(Visible)--, Activate --Show 'Home' breadcrumb link-- and --Show current page title at end--.
After that:
5. Go to /admin/config/development/performance and Clear all caches (or press "drush cr" in console)
6. Open new incognito browser window(anonymous user), and go from the start to front page (do not forget to put breadcrumbs-block on some region which is visible on all pages)
7. Breadcrumbs will be cached and invisible on all pages like on front-page.
Comment #11
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedComment #12
Majdi CreditAttribution: Majdi commentedI can confirm that but I think this has nothing to do with bootstrap, if you set any page as front page under site settings, you wont be able to see the breadcrumb anymore and you can have this behavior with any theme, I think it's related to core.
Comment #13
ion.macaria CreditAttribution: ion.macaria as a volunteer commentedComment #14
rroels CreditAttribution: rroels commentedI am experiencing the same issue in Drupal 8.3.7. The whole breadcrumbs block is simply not shown on the frontpage, everywhere else it works fine. I'm using a custom template so it's not a template setting. I even tried adding "<front>" and "*" to the breadcrumb block's page restriction tab but that changes nothing.
Something that is also interesting to note is that the "MYTEMPLATE_preprocess_breadcrumb( )" function in my custom template is never called for the frontpage. It works fine everywhere else. I thought I could hack together a fix by overwriting the $variables['breadcrumb'] variable for the frontpage there, but the function isn't even called.
This seems like an internal issue/bug to me.
Comment #15
markhalliwellThis sounds like, perhaps, a caching issue but may have already been solved by #2829588: Provide a "url.path.is_front" cache context to allow contributed themes to move global "is_front" variable back.
In fact, this allowed Bootstrap to add back the global "is_front" template variable #2829585: Add the "is_front" variable back to all templates.
I'm still not convinced that this is an actual issue as I have not seen this happen personally (it would be a pretty obvious bug).
That being said, most "front pages" of websites rarely have breadcrumbs of any kind.
If anything, it may be a byproduct of the increasing learning curve for Drupal, one which now includes render caching and contexts.
I think for this issue to move forward as an actual bug, someone will need to pin point where this bug is via code/patch.
Thus, postponing for now (and moving to proper IQ).
Comment #16
jbitdrop CreditAttribution: jbitdrop commentedAs @markcarver has already stated, I would also rather see this issue here as a basis for a possible feature request and before this as a conceptual decision to discuss, because breadcrumbs are mostly not awaited on frontpage. And this has a possible chance to become "works as designed". Despite of that I wonder where or when I ever have seen a breadcrumb on frontpage or do I miss something here from the issue summary?
Comment #17
skyhawk669 CreditAttribution: skyhawk669 commentedThe issue here isn't about whether the breadcrumbs are displayed on the front page or not, I think most of us agree that they have no place on a front page.
The problem @ionmacaria is describing, which I'm having as well, is that if you visit the site main page as an anonymous user, then go to another (sub) page where the breadcrumbs should appear, they do not. If that sub page (or any other) is visited directly after cache being cleared (without visiting the front page first), then the breadcrumbs appear correctly as they should.
In my case they don't disappear on all sub pages, but only on first level sub pages (http://www.example.com/subpage, http://www.example.com/subpage2, etc.). Also, for me, this happens not only for anonymous users, but also any logged in user besides administrator.
Like @ionmacaria mentioned, the only workaround is to go into the breadcrumbs block configuration and hide for listed pages and include the front page there (even though the breadcrumbs wouldn't show up anyway), then this issue disappears.
As far as I can see, this isn't dependent on the theme used, I saw the same issue on Seven and Bartik as well...
There must be some bug somewhere in the breadcrumb logic in core.
Comment #19
gallegosj CreditAttribution: gallegosj as a volunteer commentedI'm experiencing this exact issue and it's been driving me insane. @skyhawk669 #17 described it perfectly. If I clear my site cache and then log out I'm returned to the home page. Breadcrumbs don't get loaded to the new cache build since I'm starting on the home page as an anonymous user, so they're not showing up on sub pages either.
Comment #20
donapis CreditAttribution: donapis commentedi'm also having the same problem.
Comment #21
Akansh Pandey CreditAttribution: Akansh Pandey commentedIssue lies in \core\modules\system\src\PathBasedBreadcrumbBuilder.php file.
Here they have written :
// Do not display a breadcrumb on the frontpage.
if ($this->pathMatcher->isFrontPage()) {
return $breadcrumb;
}
When I exclude these lines, my breadcrumb preprocess works in desired way.
I would suggest you to override this file.
I hope this suggestion is helpful to you.
Comment #22
sarikak CreditAttribution: sarikak commented@Akansh Pandey
Thanks a lot.
I was searching for this one.You saved my day.
Comment #23
tce CreditAttribution: tce commentedI'm seeing this also. If I clear caches and I crawl the site using software, visiting pages then shows the missing breadcrumb.
- Using Drupal version 8.5.3
- I don't have breadcrumbs on my front page
- Breadcrumbs are on my Commerce product pages
The solution in shown in #21 only seems to work on my local copy of the site (with all caching turned on) but not on production for some reason.
I'm actually using my own breadcrumb builder for product page, code is:
Breadcrumbs work fine for product pages when logged in. Also works fine clearing the cache and straight away visiting the product page. It doesn't work if I clear the site, crawl the site, then visit the product page.
Comment #24
jbitdrop CreditAttribution: jbitdrop as a volunteer and at MAROQQO studios commentedI think we should first clear what this issue is about, edit the summary, finalize the roadmap and start providing ideas for patches. Otherwise this issue will keep being postponed.
Comment #25
pixelpreview@gmail.com CreditAttribution: pixelpreview@gmail.com commentedI have the same problem with drupal 8.5, breadcrumb disappears after clear cache when we are redirect to the home
all pages loose the breadcrumb
Comment #26
rondog469 CreditAttribution: rondog469 commentedI am using 8.5.6 and having this issue as well. On my homepage, I don't have breadcrumbs. If I clear cache on the front page and then visit a subpage, the breadcrumbs are gone. If I clear cache on a subpage, the crumbs work fine.
Comment #28
jeramy CreditAttribution: jeramy as a volunteer commentedI was having the same problem as described by the OP ion.macaria, and in #17 by skyhawk669. Following the instructions in #17 worked for me on each site I had experiencing this issue.
Drupal version : 8.6.1
I went Home>Administration>Structure>Block Layout and clicked 'Configure' on my Breadcrumbs block. Under the Pages tab, I set 'Hide for the listed pages' and added
<front>
to the 'Pages' textbox. I changed this on each of my sites experiencing this issue and it worked in each case.Comment #29
tce CreditAttribution: tce commentedWow, just followed the instructions in #28 and it appears to work. Will keep an eye on it. Thanks jeramy.
Update: some breadcrumbs are still missing using solution #28
Comment #30
huzookaFound a test case when this fails (and I have fix as well).
Steps to reproduce
user
,node
,path
and obviouslyblock
modules (it is important not to have view enabled or if it is, ensure thatviews.view.frontpage
is disabled)/breadcrumb-test
page.front
insystem.site
tonode/[NODE_A-ID]
/breadcrumb-test
Expected
You can see the breadcrum containing the 'Home' link.
Current behavior
Breadcrumb is missing.
Explanation
IMHO the issue caused by the faulty usage of the cache contexts in PathBasedBreadcrumbBuilder. When we have a breadcrumb render cached for the front page, it's only cache context will be the
url.path.parent
. This happens because of the next condition @150.In this case, PathBasedBreadcrumbBuilder will return a renderable array with only the cache context
url.path.parent
. And that context is the same even if we have only one level in our path (/breadcrumb-test
) or nothing (on the front page, obviously). And this renderable array will rendered as an empty element.So, because of that the cache context is the same for both
<front>
and for/anything-else
, Cache API correctly determines that it shouldn't create an another rendered instance for this breadcrumb.If the first page visit (with cold cache) gets any other node page, the condition @150 wont be true, the breadcrumb will have markup (a home link at least).
The solution is to add
url.path.is_front
cache context to PathBasedBreadcrumbBuilder@147. This will produce only one more render cache instance from breadcrumb, which is acceptable imho.Comment #31
huzookaTest-only patch.
Comment #33
huzookaComment #34
huzookaWorths a mention that I was unable to use
AssertBreadcrumbTrait
. It does not care about that the 'Home' crumb is printed on the page or not :(.Comment #37
cestmoi CreditAttribution: cestmoi commentedI experienced this bug after updating from 8.5.6 to 8.6.1
Breadcrumbs do not show link for current node if it's a parent page. When it's a child page breadcrumb shows links for parent pages. Sometimes breadcrumb shows the word "Node" with a link instead of the current node title.
I disabled the core Frontpage view and I do have a custom Frontpage view in place.
I tried all fixes mentioned above and nothing worked.
I tested on a fresh install on simplytest.me and the breadcrumb menu only showed the "Home" link no more and regardless of the type or level of node I am on.
Comment #38
huzooka@cestmoi
I'm sure that if you apply #33, it will be fixed.
Failed tests (Node translation ui and breadcrumb
kernelunit test) are complaining about the unexpectedurl.path.is_front
cache contexts.It's obvious that this fix can't be committed to core; but we'll see the further tasks (solution) only after a review (ideally from a core maintainer).
Comment #39
huzookaComment #40
cestmoi CreditAttribution: cestmoi commented@huzooka
Thank you but unfortunately it didn't make any change for me !
Still no breadcrumb for any page that is a top level parent page while it shows links for parent/s page/s when the current node is a child page. That's still better than what I had on a fresh test on simplytest.me where nothing is shown but the "Home" link no matter what node you're at. I reported this as a bug here as I'm not sure if it's directly related to the bug reported here.
Comment #41
huzooka@cestmoi
You need to alter the breadcrumb in your case. Core does not outputs the active route's title, that's why it adds `url.path.parent` by default. Here's the motivation/explanation: https://www.drupal.org/node/2713593
I wont assume that your use case will be considered as a bug.
In your case I would replace the class of the
system.breadcrumb.default
service with a custom class which extends the originalPathBasedBreadcrumbBuilder
and customize it'sbuild
method, so here:You should add
url.path
instead ofurl.path.parent
.Note that you'll get lot more context of your breadcrumb in this case.
Comment #42
huzookaExpected test fails reduced to two assertions:
Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildOnFrontpage
andDrupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithOnePathElement
both will fail.Test-only patch was only renamed.
Comment #43
cestmoi CreditAttribution: cestmoi commented@huzooka
I applied your suggestion and still no change whatsoever !
Idk if it's me doing something wrong or missing something.
1. I edited the function in
core\modules\system\src\PathBasedBreadcrumbBuilder.php
so it became :2. I rebuilt cache
drush cr
3. Tested. No change ! :-/
So it's a core by-design to only have the link for the parent nodes and no links if current page is a top parent node :-?
In such case then it's working as designed in my case (except for the occasional "Node" replacing the actual node Title).
But the case I reported from my test on simplytest.me where breadcrumb only has a "Home" link no matter what page you're on is a bug. No ?!
Comment #44
huzookaMy advice is that at least provide a 'steps to reproduce' to #3001425: breadcrumb not showing current page title when it's a top parent node, after updating to 8.6.0.
Tis issue is about Breadcrumbs disappears when starting with front-page after cache rebuild.
Comment #45
catchThis should always add the url.path.is_front cache context unconditionally.
Comment #46
catchBumping to major since this is a site-visitor facing bug.
Comment #47
huzookaComment #48
huzookaLet's add the passing patch :)
I dont add a test-only one since it would be the same as the one in #33.
Comment #49
catchLooks right to me now, thanks!
Comment #50
jeramy CreditAttribution: jeramy as a volunteer commentedThe patch worked for me as well. Thank you!
Comment #51
catchCommitted and pushed 1506516dc3 to 8.7.x and 59bcf5befc to 8.6.x. Thanks!