Closed mdapena closed 3 weeks ago
Thanks for reporting. The base_url
is set by MkDocs, which is controlled by mike, so I'm very confident that this is an upstream issue. Our mike integration only loads the versions.json
ands renders the version selector. The fact that search is broken, denotes that the base_url
is invalid. Since the 404 page needs an absolute base URL (as any path must map to it), the base URL is invalid and the assets can not be loaded. There seems to be an upstream issue:
This issue only occurs when Mike's versioning is enabled; the 404-page functions correctly without it.
Please take this discussion upstream, unless you can proof that this happens solely with Material for MkDocs, and works for other themes. I'm confident that this is a mike issue, not a MkDocs or Material for MkDocs issue.
Other than that, thank you for investing the time to write up a very detailed issue and explanation. Please note that we're developing a new way for working with multi-project builds, which includes multi-language and versioning. Our goal is to provide versioned documentation that just works locally, and does not need to be deployed to function.
Thanks for the quick reply! That was fast⚡
Yeah, it makes total sense that if the base_url
is controlled by MkDocs and the mike
package is the one that uses it to build the 404 page, then this is definitely an upstream issue. I’ll take this to mike's issue tracker and see if I can find the root cause.
Other than that, thank you for investing the time to write up a very detailed issue and explanation. Please note that we're developing a new way for working with multi-project builds, which includes multi-language and versioning. Our goal is to provide versioned documentation that just works locally, and does not need to be deployed to function.
Wow! I wasn’t aware of this, but it sounds amazing! I really appreciate you sharing this information and your commitment to improving the project. I’m excited to see how it all comes together!
Context
While working on my documentation with MkDocs Material and Mike's versioning integration, I encountered an issue after fixing some broken links. I noticed that the
404-page
wasn’t functioning as expected; for example, the versioning selector was missing, and the search input was stuck on initializing.To determine if this was just a problem with my setup, I did some digging and found that other documentation sites using Mike's versioning integration were experiencing the same issue. Here are a few examples:
While searching for errors, I discovered that when the
404-page
is loaded, it throws the following error (or something similar):After further investigation, I found that the
404.html
page was being built incorrectly. Its resource paths were prefixed with/package_name/{version or alias}
or just/{version or alias}
in some cases, even though it should have the same resource paths as theindex.html
page since it’s in the root directory of that version build. As a result, the404-page
couldn’t find its resources, which led to the errors I was encountering.While trying to confirm and fix this issue, I found a temporary workaround: manually updating the resource paths in the
404.html
page to match the actual file locations in the build (similar to those inindex.html
). You can see the workaround in action in my documentation here:Bug description
When using MkDocs Material with Mike's versioning integration, the
404.html
page is generated with an incorrect base URL. Specifically, the base URL has a prefix of/package_name/{version or alias}
or just/{version or alias}
in some cases, even though the file is located at the root level of the version build. It should have the same resource paths as theindex.html
page.This incorrect base URL results in broken links for essential resources, such as JavaScript assets, leading to functionality issues on the
404.html
page, including a non-working search bar and a missing versioning selector.This issue only occurs when Mike's versioning is enabled; the
404-page
functions correctly without it. As mentioned in the context section, I confirmed this issue and found a workaround by manually updating the resource paths to remove the invalid prefix.PS: Thank you for this amazing package! 😄
Related links
Reproduction
While I will include a
reproduction.zip
file with relevant information about my system and other important details, creating a fully functional reproduction is not feasible. Runningmike serve
locally requires a repository with a deployed and configuredgh-pages
branch. (See Viewing Your Docs.)However, the
example-versioning
provided in the MkDocs Material documentation serves as a suitable reproduction example, as it focuses solely on the versioning setup:Steps to reproduce
example-versioning
repository from MkDocs Material: github.com/mkdocs-material/example-versioning.README
file to configure the versioning (See How to set up versioning).mike serve
to start the local server or go to the deployedgh-pages
....gh-page-url/404
.404-page
, check the console for any error messages or try using the search bar at the top.Browser
No response
Before submitting