Prevent path based breadcrumb in theme, or, don't show breadcrumbs for 403/404 responses? I am looking to do one of these solutions for a users 'contact' page. When a user has unchecked "Personal Contact Form", and someone accesses that URL (user/id/contact), the breadcrumb displays the users username in the breadcrumb. 

The username in the breadcrumb is not desirable, because some people make their email address their username, so:


How can I disable the breadcrumb from displaying on 403/404 responses, or
How can I disable the path based breadcrumb service outright?
You could add a visibility condition to the breadcrumb block. For 404 there is this module block_in_page_not_found and if you negate the condition the block is displayed on all pages other than 404's:



If you want to exclude 403 pages as well you can extend this module and add a check for

$status-&gt;getStatusCode() == 403


to Drupal\block_in_page_not_found\Plugin\Condition\PageNotFoundRequest::evaluate.

Or use the patch from this issue Allow blocks to be configured to show/hide on 403/404 pages, when it applies again.