Rift supports custom error page generation so that you can gracefully handle broken links, missing content, or unexpected conditions in your static site. Since Rift is a static-first framework, error pages are pre-rendered like any other page and served by your hosting provider in response to 404 or 500-type errors.
An error page is a fallback route that is shown when no other content matches a given path. The most common is a 404 Not Found page, which appears when the user visits a URL that doesn’t map to any controller or generated page.
To add a basic 404 page to your site, simply create a file at:
src/site/404.njk
This file is treated like any other page — it can include frontmatter, a layout reference, and even dynamic logic using Nunjucks or your templating language of choice.
If your site uses multiple locales, you can define localized 404 pages using the same i18n strategy used for content pages. For example:
src/site/en/404.njk src/site/fr/404.njk
When running Rift in development mode, unmatched routes will serve your 404 page
automatically (if defined). This helps you test error UX during development. You can also directly navigate
to /404.html in your browser to preview the page.
Static hosting providers typically serve a file named 404.html when a
request does not match any known file path. Rift’s job is to generate that file. Your hosting platform then
handles routing errors to that output.
Rift does not treat error pages as special in terms of how they are built. The 404
page is just a page with a specific permalink (404.html) and optional layout or controller
logic. This means you can:
src/site/404.html or 404.njk to define a custom not-found pagepermalink: 404.html so your host recognizes it