How can I show the user login block on the 403 page? With D8, I have a node (content type: basic page) that I use as a custom 403 (access denied) page.

I set this as the custom 403 page on: /admin/config/system/site-information.  The path is /node/21, and the alias is /error/403.

On the block admin page, I added the user login block to the content region.  I added the restriction "show only on certain pages":


/error/*
/view/*
/node/21


I have a view that requires "add content type ABC permission" to access.  The path to the view is /view/abc.  The anonymous user does NOT have this permission.

So, as an anonymous user, I go to /view/abc and am shown the content of /node/21.  BUT, the user login block is not shown.

If I go to the block administration screen and remove the "show only on certain pages" restriction, then I see the block as the anonymous user on /view/abc, but I don't want to show the login block on every single page; I only want to show it on the pages that are 403s.

What is the "path" to use for the user login block to only show it on a custom 403 page?
One approach is to add page templates to your theme registry:

function MYMODULE_theme_suggestions_page_alter(array &amp;$suggestions, array $variables) {

  //Allow theming the site error pages
  $route_name = \Drupal::routeMatch()-&gt;getRouteName();

  switch ($route_name) {
    case 'system.401':
    // Unauthorized Access.
    $error = 401;
    break;

    case 'system.403':
    // Access Denied.
    $error = 403;
    break;

    case 'system.404':
    // Page Not Found.
    $error = 404;
    break;
  }

  if (isset($error)) {
    $suggestions[] = 'page__' . $error;
  }

}


Then in page--403.html.twig you can render a specific block with Twig. See: How to embed a view in a specific node? and Programatically print blocks in twig

*A reason I like this approach is that the Login block is a Drupal core block, not a custom one. You can just carry around a nice 403 template file and always know it will render out this block. The preprocess function above seems like the least invasive and time consuming (from looking at different approaches), plus it gives the ability to theme these error pages. I think it is ideal to utilize template files for error pages.