vivomedia / neos-notfound
Neos CMS package that renders a normal editable page for 404 errors, aware of content dimensions
Package info
github.com/VIVOMEDIA/neos-notfound
Type:neos-plugin
pkg:composer/vivomedia/neos-notfound
Requires
- php: >=8.2
- neos/neos: ^9.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Renders a normal, editable Neos page as the error page for "404 Not Found" (and "410 Gone") responses.
- The requested URL stays as it is (no redirect) and the response keeps its status code.
- Works with content dimensions: the 404 page is rendered in the dimension that matches the requested URL,
e.g.
/de/foooo.htmlrenders the German and/fr/foooo.htmlthe French variant of the 404 page. - XLIFF translations are rendered in the language of the 404 page.
Requirements
- Neos 9.x
- PHP 8.2+
Installation
composer require vivomedia/neos-notfound
Setup
1. Create a 404 page type
The 404 page is identified by its node type. Add the mixin VIVOMEDIA.NotFound:Mixin.NotFoundDocument to a
document node type of your site package. Usually you extend your regular page type, so that the 404 page
looks like every other page:
# Vendor.Site/NodeTypes/Document/NotFound.yaml 'Vendor.Site:Document.NotFound': superTypes: 'Vendor.Site:Document.Page': true 'VIVOMEDIA.NotFound:Mixin.NotFoundDocument': true ui: label: 'Not found page' properties: hiddenInMenu: defaultValue: true
Provide the Fusion rendering for the new node type as for any other document, e.g.:
prototype(Vendor.Site:Document.NotFound) < prototype(Vendor.Site:Document.Page)
2. Create the page
Create one page of that type anywhere in your site. The URI path segment does not matter.
With content dimensions, create a variant of the page for each dimension (or rely on your dimension fallbacks). If no 404 page exists in the resolved dimension, the default Neos error page is rendered.
Configuration
All options live under VIVOMEDIA.NotFound in Settings.yaml:
| Option | Default | Description |
|---|---|---|
nodeType |
'VIVOMEDIA.NotFound:Mixin.NotFoundDocument' |
Node type (usually a mixin) that marks the 404 page. The first document of this type in the site is used. |
statusCodes |
[404, 410] |
HTTP status codes that render the 404 page. Must be part of the Flow rendering group notFoundExceptions (403, 404, 410). Other codes use the default Neos error page. |
languageDimension |
'language' |
Name of the content dimension whose value is used as Flow i18n locale for XLIFF labels. Set to null to disable the locale handling. |
Example:
VIVOMEDIA: NotFound: nodeType: 'Vendor.Site:Document.NotFound' statusCodes: [404] languageDimension: 'locale'
If you configure this in a site package, make sure it is loaded after this package by adding
"vivomedia/neos-notfound": "*" to the require section of the site package's composer.json.
License
MIT, see LICENSE.