Custom 404 page

I just added a DTML Method with id "standard_error_message" with the content:

<!DOCTYPE html>
<html>
  <head>
    <title><dtml-var title_or_id></title>
    <meta charset="utf-8" />
  </head>
  <body>
<dtml-if "error_type=='NotFound'">

Custom Page not found: 404

</dtml-if>
  </body>
</html>

With zope5 is this the right way to have a custom 404 page? Anything else I suppose to do?

Thank You

Hi, in Plone 6 (Classic-UI) there's the plone.app.redirector package, which tries to find old/new paths from moved objects, URL-aliases and so on before we see the Not found page.

Anyway the delivered 404 page template is located in Products.CMFPlone.browser.templates.error_message.pt which you can override with z3c.jbot (see the docs for overriding help).

Giampiero Benvenuti via Plone Community wrote at 2024-11-11 08:59 +0000:

...
With zope5 is this the right way to have a custom 404 page? Anything else I suppose to do?

Zope 4+ (and therefore Zope 5) supports 2 ways to customize
the error handling: 1. error views and 2. standard_error_message.

For details look at ZPublisher.WSGIPublisher._exc_view_created_response.

1 Like