--- eleventyNavigation: key: Advanced usage title: Advanced usage parent: CodebergPages order: 999 --- ## Custom error page for 404s You can replace the default 404 error page that Codeberg Pages will show for missing pages with your own version if you prefer. To do so start by writing your own HTML file that you want to serve instead. After creating the HTML with your custom error message, save it as `404.html` in the root of your repository that you use to serve your Codeberg Page. From then on, your `404.html` file will be served when the error is encountered. ## Redirects Redirects can be created with a `_redirects` file with the following format: ```text # Comment from to [status] ``` - Lines starting with `#` are ignored - `from` - the path to redirect from - `to` - the path or URL to redirect to - `status` - status code to use when redirecting (optional, default 301) ### Status codes - `200` - returns content from specified path (no external URLs) without changing the URL (rewrite) - `301` - Moved Permanently (Permanent redirect) - `302` - Found (Temporary redirect) ### Examples #### Simple redirect Redirects a specific path. ```text /example https://example.com/ 301 /path /other-path 301 ``` #### SPA (single-page application) rewrite Redirects all paths to `/index.html` for single-page apps. ```text /* /index.html 200 ``` #### Splats Redirects every path under `/articles` to `/posts` while keeping the path. ```text /articles/* /posts/:splat 302 ``` {% admonition "Warning" %} `:splat` should always be the last element of the path, so something like `/*/ /:splat.html` is not a valid rule. {% endadmonition %} Example: `/articles/2022/10/12/post-1/` → `/posts/2022/10/12/post-1/`