Skip to content

Support custom 404 page #227

@melaniewalsh

Description

@melaniewalsh

Describe the bug

I know that Jupyter Book will not work predictably with custom Sphinx extensions, but I've been trying to integrate this Sphinx Not Found Page extension into my Jupyter Book so that I can have a custom 404 page. And I think this could be potentially useful for all Jupyter Book users.

Anyway, when I use this extension, I get the following error:

An error happened in rendering the page 404.
Reason: ValueError("'/' does not start with '/Users/melaniewalsh/mybookname'")

@humitos has been helping me debug this issue and usefully identified that there seems to be a problem in sphinx-book-theme in the function find_url_relative_to_root, which is called from generate_nav_html.

So I was wondering if there were any suggestions about how to make the Sphinx Not Found extension work with the Sphinx Book Theme. Thanks!

To Reproduce

  1. Add Sphinx Not Found Page extension to _config.yml
sphinx:
  extra_extensions: 
  - notfound.extension  
  config:
    notfound_context:
        body: "<h1>Page not found.</h1>"
    notfound_no_urls_prefix: True
  1. Build Jupyter Book
  2. See error
An error happened in rendering the page 404.
Reason: ValueError("'/' does not start with '/Users/melaniewalsh/mybookname'")

Expected behavior

Custom 404 page is built that preserves CSS and JavaScript from Sphinx Book Theme

Environment

  • Python Version [e.g. 3.7.1]: 3.8
  • Package versions or output of jupyter-book --version:
    Jupyter Book: 0.8.2
    MyST-NB: 0.10.1
    Sphinx Book Theme: 0.0.36
    MyST-Parser: 0.12.10
    Jupyter-Cache: 0.4.1
    NbClient: 0.4.0
  • Operating System: Mac OS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions