Not found
Middleware to show a custom page on 404 errors.
Options
- root string
The root folder to look for the 404 page
Default:"/opt/build/repo/_site"
- page404 string
The path to the 404 page
Default:"/404.html"
- directoryIndex boolean
Show the directory index if the page404 is not found
Default:false
Description
This middleware shows a not-found page on 404 errors. Optionally, it can create a directoryIndex
for folders.
Installation
This middleware must be used with Lume's HTTP Server. To use it in production, you need a host running a Deno server, like Deno Deploy.
Create an entry point file (for example, serve.ts
) with the following code:
import Server from "lume/core/server.ts";
import notFound from "lume/middlewares/not_found.ts";
const server = new Server();
server.use(notFound({
page404: "/404.html", // Default value
}));
server.start();
Local development
This middleware is used by default by Lume in --serve
mode with the value of the page404
option.