Skip to content

Choosing 404.md over NotFound.vue #576

Closed
@sebiniemann

Description

@sebiniemann

Feature request

What problem does this feature solve?

After using vuepress a lot, I stumbled over two problems with the current handling of missing routes.

  1. Instead of delivering a page defined at the site level, like the content of a /404.md file, the whole error pages is defined by NotFound.vue, at the theme level. This couples the layout with the content and changes he behaviour compared to normal pages using Layout.vue, where <Content> is available. Additional information like a list of site specific, helpful links or messages can therefore only be added over config.js or similar places, reducing the ease of use, compared to markdown files.
  2. If the server responses to missing route with the content of an error page itself, like /404.html, vuepress immediately changes the page's content to the one in NotFound.vue, hiding the previously content after a fleeting glimpse.

I am also not sure if the latter one was intended, as /404.md pages are especially handled by vuepress (see the following code snippet from https://github.com/vuejs/vuepress/blob/master/lib/build.js).

  // if the user does not have a custom 404.md, generate the theme's default
  if (!options.siteData.pages.some(p => p.path === '/404.html')) {
    await renderPage({ path: '/404.html' })
  }

However, it is only rendered if example.org/404.html is directly accessed, but hidden if only its content is delivered for routes like example.org/missing.html. Which is the fixed behaviour of AWS S3 and CloudFront, delivering only the content of an error page, without causing an additional redirect.

What does the proposed API look like?

How should this be implemented in your opinion?

  • Making the content of a site's /404.md accessible to the theme's NotFound.vue via <Content>.
  • Generating /404.html based on NotFound.vue and falling back to Layout.vue if the former is missing.^
  • Serving the component defined by /404.md instead of NotFound.vue for path: '*'.

^On a site note, this also makes it easier to generate error pages which retain the overall layout, including the header, navigation, ...

Are you willing to work on this yourself?**

Sure 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature requestRequest to add a new featureversion: nextPlanned to do or already included in the next(1.0.0) version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions