Skip to content

The 404 page

Overview

Sometimes, a user visits a URL that doesn't match up with an existing page. Maybe they typed /ashboard instead of /dashboard, and the src/Pages/Dashboard.elm file isn't loaded as intended.

Regardless of how they got there, Elm Land will need to show them a "Not found" page. By default Elm Land creates a page that only shows the message "Not found":

elm
-- ...

view : Model -> View Msg
view model =
    { title = "404"
    , body = [ text "Not found" ]
    }

Customizing the 404 page

If you'd like to show something other than "Not found", you can use the elm-land customize command to have complete control over the src/Pages/NotFound_.elm file:

sh
elm-land customize not-found

This page behaves just like any other page. You can make the not found page as fancy as you like! If you're new to pages in Elm Land, please visit the Pages section to learn more about them!

A note on catch-all vs. 404 pages

If you define a top-level catch-all route at src/Pages/ALL_.elm, it will have a higher priority than the NotFound_ module.

If you're in an existing Elm Land project, and wondering why the 404 page isn't being reached, it could be due to the ALL_.elm file!

Made for you with ❤️