Skip to content

Option to prerender 404 page #10007

@GitRowin

Description

@GitRowin

Describe the problem

I am using the static adapter. The recommended way to generate a 404 page seems to be by using the fallback option, however, this option is meant to be used to generate a SPA, so it outputs a blank HTML page. I would like my 404 page to be prerendered.

Describe the proposed solution

I propose adding an option to adapter-static to generate a prerendered 404 page.

Alternatives considered

I tried simply creating 404/+page.svelte. There are two problems with this approach:

  1. It doesn't work during development, because the server renders +error.svelte.
  2. It doesn't work when serving the file from a subdirectory, because SvelteKit uses relative paths to assets.

Problem 1 can be solved by turning the 404 page into a component and rendering it in both 404/+page.svelte and +error.svelte.

Problem 2 can be solved by setting kit.paths.relative to false.

This feels quite hacky though.

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature / enhancementNew feature or requestp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions