-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
404 page does not work outside the site root #2318
Comments
What is your |
It's empty (intentionally). I have just played with it and it generates what I want, but then it also puts the absolute URL in a few places such as the logo, which is the reason we chose not to use it in the past. Is there a way to get the behavior of site_url, but use root-relative URLs everywhere? |
The entire url system within MkDocs is carefully crafted so that you can use a built site anywhere. The only change you need to make is to adjust the If you want to break out of that mold, then you need to do some customizations of your own. At a minimum that would involve using the theme custom_dir and overriding template blocks. That would allow you to define the As I said, we are moving to making Therefore, we are not going to add a new setting. We don't need two settings which contain the same information and we don't have a large number of users requesting the option to differentiate between the information conveyed (site is or is not in a subdomain) and the inclusion of the URL in the site. That said, if a third-party theme wanted to add a setting to the So you have two options: do your own theme customizations or explore third party themes which may offer additional functionality/flexibility. |
Well setting the site_url requires knowing in advance the domain name where the doc site will be deployed. So we skipped it thinking it's optional (and I agree with your comments in the other issues, if mkdocs does not work well without it, then make it mandatory to save the pain of discovering that later). Out of curiosity, is there a particular reason it's putting the absolute URL in those few places? I can see the rest of the page links use root-relative paths when I enter a Reason I ask is, well, it's a bit weird. My Angular SPA does not need to know in advance where I will host it... so I expect other people will find it weird as well, and maybe this reasoning should be documented here. Could be that the answer is already hidden in one of the github issues/PRs and I just couldn't find it :(. |
The reasoning for the current behavior is explained in detail in this comment. In short, MkDocs is a static site generator so the behaviors of dynamically generated sites don't apply. |
After digging a bit, I think I found the cause of my confusion. But I think this is the fault of the mkdocs-material theme, which uses |
Apparently it was just fixed by squidfunk/mkdocs-material#2388. |
Since at the moment there is no localization support, we are using separate mkdocs projects per language, and each of these is generating their own 404.html page next to index.html. The end result is that index.html and 404.html is not served from the website root anymore.
While index.html has no issues since it uses paths relative to the current location, 404.html seems to use paths relative to root, making them basically useless. The layout is broken because assets cannot be loaded, and trying to navigate the docs from the served 404.html does not work either.
Excerpt from index.html (good):
Equivalent from 404.html (bad):
Edit:
Using links relative to current page does not work either, because the non-existing URL may be https://website/docs/missingpath/missingsubpath (and 404.html is placed under docs). I think the fix here is to be able to be able to make mkdocs aware of the subdir where it is going to be hosted from, something which has been proposed and rejected before.
The text was updated successfully, but these errors were encountered: