Skip to content

Docsify does not handle 404 errors gracefully #524

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

Closed
jhildenbiddle opened this issue Jun 7, 2018 · 4 comments
Closed

Docsify does not handle 404 errors gracefully #524

jhildenbiddle opened this issue Jun 7, 2018 · 4 comments

Comments

@jhildenbiddle
Copy link
Member

jhildenbiddle commented Jun 7, 2018

Sections of the UI are dependent on successfully loading the specified content. AJAX requests should be decoupled when possible to prevent one failure from causing another.

  1. If a window URL contains hash that results in a 404 on initial page load, the “404 - Not found” message appears but the external sidebar content is not loaded, thus making it difficult to navigate to another page.

    Example: https://docsify.js.org/#/foo

    • For sites that do not load an external sidebar, consider redirecting to the site root if the notFoundPage option is unspecified.
    • For sites that do load an external sidebar, load the sidebar without marking an item as active. This will allow the user to navigate away from the 404 error to another page.
  2. If an :include results in a 404 on initial load, neither the sidebar nor the other page content loads. Users are left with a blank screen, no navigation, and no idea what went wrong. The sidebar should render, as should the content with the missing :include data (perhaps a "unable to load xxx" element can be inserted where the failed :include was located).

  3. After initial load, if a user navigates to a page with an :include that results in a 404 it appears as though nothing happens (although the console reveals that a 404 error has occurred). This scenario should be handled the same way as the above :include issue: load and display the content available, perhaps with placeholder content for the failed :include.

  4. There is no way to detect a 404. This can be useful for themes that offer full-screen overlay loaders or injecting 404 content from a file rather than using the notFoundPage option. A hook.error method or a data-status attribute added to the <body> would be helpful.

@saioacoder
Copy link

Hiii jhildenbiddle

You can specify an alias to avoid unnecessary fallback, like this:

<script>
  window.$docsify = {
    loadSidebar: true,
    alias: {
      '/.*/_sidebar.md': '/_sidebar.md'
    }
  }
</script>

It works for me. I hope it helps you too. :)))

Bye :D

@jhildenbiddle
Copy link
Member Author

Thank you for the reply, @saioaRed.

I'm not sure I follow your suggestion. How does docsify's alias address the 404 issues listed above?

@mazzystr
Copy link

mazzystr commented Sep 1, 2020

Useful for CI / checkers like HTMLproofer also

I just inherited a project where the main web site is jekyll with pages/blogs containing links to a uri driven by docsify. The docsify content has a sidebar. Some of the links to the docsify content have gone stale.

We're searching for a way to verify those links.

@jhildenbiddle
Copy link
Member Author

Fixed by #2303.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants