readthedocs / sphinx-notfound-page

Create a custom 404 page with absolute URLs hardcoded
https://sphinx-notfound-page.readthedocs.io/
MIT License
48 stars 32 forks source link

Resources are not loaded for the 404 page, leading to plain html page. #167

Closed Atlinx closed 3 years ago

Atlinx commented 3 years ago

Hey all, I'm trying to copy Godot's sphinx setup and I'm using GitHub pages to host my docs. The 404 page loads successfully but it's a plain HTML page. Does anyone know what's causing this?

Untitled

Parts of my config file related to this extension:

extensions = [
    "myst_parser",
    "gdscript",
    "sphinx.ext.autodoc",
    "sphinx.ext.intersphinx",
    "sphinx.ext.viewcode",
    "sphinx_panels",
    "sphinx_tabs.tabs",
    "notfound.extension",
    "sphinxext.opengraph",
]

notfound_urls_prefix = ''

notfound_context = {
    "title": "Page not found",
    "body": """
        <h1>Page not found</h1>
        <p>
            Sorry, we couldn't find that page. It may have been renamed or removed
            in the version of the documentation you're currently browsing.
        </p>
        <p>
            If you're currently browsing the
            <em>latest</em> version of the documentation, try browsing the
            <a href="/en/stable/"><em>stable</em> version of the documentation</a>.
        </p>
        <p>
            Alternatively, use the
            <a href="#" onclick="$('#rtd-search-form [name=\\'q\\']').focus()">Search docs</a>
            box on the left or <a href="/">go to the homepage</a>.
        </p>
    """,
}
humitos commented 3 years ago

Does it works if you use None for notfound_urls_prefix instead? See https://sphinx-notfound-page.readthedocs.io/en/latest/faq.html#does-this-extension-work-with-github-pages

What's the URL of your project?

Atlinx commented 3 years ago

I've tried using None and that didn't work either. Here's the link to my repo and here's the link to the GitHub pages site. Interestingly, this only seems to happen on GitHub pages -- I've launched a readthedocs version of my docs and the 404 page works.

humitos commented 3 years ago

Hi @Atlinx! This is because you are not using a custom domain for your GitHub page, so you need FracturalVNEDocs/ as prefix. If you add that prefix it will work. Please, let me know.

If it works, feel free to send a PR updating the FAQ to mention this.

Atlinx commented 3 years ago

@humitos It looks like using the FracturalVNEDocs/ doesn't work either. I've updated the repo and now it's using the plain 404 page as the default home page.

Atlinx commented 3 years ago

@humitos It looks like using the FracturalVNEDocs/ doesn't work either. I've updated the repo and now it's using the plain 404 page as the default home page.

Whoops! I forgot to add a starting "/" on my prefix as specified by your documentation. It all works now, thanks!