Styling the error pages
Drupal provides some suggestions for typical 4xx
errors, such as File not found or Access denied.
Every time an error occurs on Drupal, the system triggers a redirect to one of those routes:
system.401
: The user is trying to access an unauthorized resourcesystem.403
: The user is trying to access a forbidden resourcesystem.404
: The user is trying to access a resource that doesn’t exist
Every time the page for one of those routes is rendered, the system looks for a related page template:
page--401.html.twig
page--403.html.twig
page--404.html.twig
For example, for a Page not found error, Drupal checks whether a template called page--404.html.twig
exists in the currently enabled theme.
To see this in action, follow these steps:
- Create a
templates/layout/page--404.html.twig
file with this content:{{ include('@organisms/page-error.html.twig', {
srMessage: 'Error'|t...