# Custom error pages

If you want to add custom error pages, you can follow the standard process described here: [Custom error pages](https://www.progress.com/documentation/sitefinity-cms/administration-custom-error-pages).

When the URL of the custom error page contains the error code (for example, `~/404`), you must add an additional Next.js route to serve it. Without this route, the page cannot be edited in the backend. To see the supported error codes, see [Supported error codes](https://www.progress.com/documentation/sitefinity-cms/administration-custom-error-pages#supported-error-codes).

## Configure settings

1. In Sitefinity CMS backend, navigate to *Administration » Settings » Advanced » Pages » Custom Error Pages » Error Types » 404*.
2. Check the *Redirect* option.

This ensures that 404 requests are routed through the route for the custom page and are cached according to the cache settings.

## Create the routing

To create a 404 page, first create the route and then add a page.tsx file for that route.

1. Navigate to *//src/app/404/page.tsx.*
2. Use the following sample to create the route.

   ```TSX
   import { Metadata } from 'next';
   import { RenderPage, pageMetadata } from '@progress/sitefinity-nextjs-sdk/pages';
   import { templateRegistry } from '../template-registry';

   export async function generateMetadata({ params, searchParams }: any): Promise<Metadata> {
       return await pageMetadata({ params: {slug: ['404']}, searchParams });
   }

   export default async function Page({ params, searchParams }: any) {
       return await RenderPage({ params: {slug: ['404']}, searchParams, templates: templateRegistry });

   }

   ```
