Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choosing 404.md over NotFound.vue #576

Closed
sebiniemann opened this issue Jun 12, 2018 · 3 comments
Closed

Choosing 404.md over NotFound.vue #576

sebiniemann opened this issue Jun 12, 2018 · 3 comments
Labels
type: feature request Request to add a new feature version: next Planned to do or already included in the next(1.0.0) version

Comments

@sebiniemann
Copy link

sebiniemann commented Jun 12, 2018

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 👍

@ulivz ulivz added the type: feature request Request to add a new feature label Jun 13, 2018
@ulivz
Copy link
Member

ulivz commented Jun 13, 2018

Good idea, but we have already covered this area in the development of plugin API, so please wait, thank you.

@ulivz ulivz added the TBD label Jun 13, 2018
@ulivz ulivz added version: next Planned to do or already included in the next(1.0.0) version and removed TBD labels Aug 20, 2018
@danstans
Copy link

danstans commented Jan 6, 2019

Sorry to reopen, but i'm not sure how to go about implementing this myself. I would prefer not to use a different layout for 404 pages and the 404.md idea seems to be a good work around. I'm not sure I understand the plugin API well enough to tell if it's been implemented.

@Gerhut
Copy link
Contributor

Gerhut commented Jun 28, 2022

same question here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Request to add a new feature version: next Planned to do or already included in the next(1.0.0) version
Projects
None yet
Development

No branches or pull requests

4 participants