mkdocs: Use use_directory_urls: false breaks on empty site_url
When setting the site_url to null (default) and use_directory_urls is false to make the docs browse-able in a user friendly fashion accessible from the local file-system, in the default mkdocs theme the link to the site on the site-name:
<a class="navbar-brand" href=".">{{site_name}}</a>
is missing the /index.html added to the existing href . (dot).
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 36 (34 by maintainers)
Commits related to this issue
- Fix url-filter with file urls on an empty site_url, closes #2189 Previously when "use_directory_urls" was false and "site_url" empty (e.g. documentation for fs), the link to the home-page / main inde... — committed to ktomk/mkdocs by ktomk 4 years ago
- Fix url-filter with file urls on an empty site_url, closes #2189 Previously when "use_directory_urls" was false and "site_url" empty (e.g. documentation for fs), the link to the home-page / main inde... — committed to ktomk/mkdocs by ktomk 4 years ago
- Fix url-filter with file urls on an empty site_url, closes #2189 Previously when "use_directory_urls" was false and "site_url" empty (e.g. documentation for fs), the link to the home-page / main inde... — committed to ktomk/mkdocs by ktomk 4 years ago
- Fix url-filter with file urls on an empty site_url, closes #2189 Previously when "use_directory_urls" was false and "site_url" empty (e.g. documentation for fs), the link to the home-page / main inde... — committed to ktomk/mkdocs by ktomk 4 years ago
- Fix url-filter with file urls on an empty site_url, closes #2189 Previously when "use_directory_urls" was false and "site_url" empty (e.g. documentation for fs), the link to the home-page / main inde... — committed to ktomk/mkdocs by ktomk 4 years ago
- Fix url-filter with file urls on an empty site_url, closes #2189 Previously when "use_directory_urls" was false and "site_url" empty (e.g. documentation for fs), the link to the home-page / main inde... — committed to ktomk/mkdocs by ktomk 4 years ago
- Fix url-filter with file urls on an empty site_url, closes #2189 Previously when "use_directory_urls" was false and "site_url" empty (e.g. documentation for fs), the link to the home-page / main inde... — committed to ktomk/mkdocs by ktomk 4 years ago
- Ensure site_url and use_directory_urls do not conflict. The site_url config option is now required. If it is set to an empty string, then use_directory_urls will be forced to false. Each will issue a... — committed to waylan/mkdocs by waylan 3 years ago
- Ensure site_url and use_directory_urls do not conflict. The site_url config option is now required. If it is set to an empty string, then use_directory_urls will be forced to false. Each will issue... — committed to mkdocs/mkdocs by waylan 3 years ago
- Set site_url for mkdocs mkdocs/mkdocs#2189 ```text WARNING - Config value: 'site_url'. Warning: This option is now required. Set to a valid URL or an empty string to avoid ... — committed to br3ndonland/inboard by br3ndonland 3 years ago
- Remove `site_url` and trailing slash from docs br3ndonland/inboard#34 br3ndonland/inboard@36eca9d br3ndonland/inboard@a877045 https://www.mkdocs.org/user-guide/configuration/#site_url https://www.mk... — committed to br3ndonland/inboard by br3ndonland 3 years ago
- Remove `site_url` and trailing slash from docs br3ndonland/fastenv#1 br3ndonland/inboard#34 br3ndonland/inboard@9943112 https://www.mkdocs.org/user-guide/configuration/#site_url https://www.mkdocs.o... — committed to br3ndonland/fastenv by br3ndonland 3 years ago
May I ask why you need the complete url of the website to build the documentation website?
If I could do
I could upload the same build on different hosts if it was possible.
The current error I get when I have this error logged:
NB: I ask about this here because it’s the issue where it was discussed to make
site_urlmandatory whenuse_directory_urlsistrueIn the 1.2 release (which will require a site_url) the easiest way to do this would be through an environment variable, which is another new feature of 1.2. See more here.
First, use the
!ENVtag in the config file:Then on the commandline do:
This is indeed a bug of MkDocs which should be fixed. We also had this problem as part of Material for MkDocs, which I was able to mitigated with https://github.com/squidfunk/mkdocs-material/commit/454339bd359b8708aaf1b2cfb22098b158d475d3 – just in case you’re using this template. Other than that, the commit may be helpful for other theme devs.
@MathieuPuech Thanks for the suggestion https://github.com/mkdocs/mkdocs/issues/2189#issuecomment-847816816 In https://github.com/mkdocs/mkdocs/pull/2503 I want allow specifying just the path, not the whole URL. Of course,
site_urlwill stop being mandatory anyway, so you probably don’t care so much about that ability anymore, but it gave me an idea 😃I don’t feel I’m proficient enough in the internal mechanics of MkDocs to decide whether that covers all cases, but it sounds good to me in general. In essence, we have three cases that should be covered:
site_urlset anduse_directory_urls: true(default)site_urlset anduse_directory_urls: falsesite_urlnot set anduse_directory_urls: true(must be)However, there might be cases where people don’t set the
site_urland useuse_directory_urls: true, e.g. when they want to deploy the same documentation on different domains. As I understood, you’d want to issue a warning then, making it impossible to build with--strict. I’d expect some issues rolling in for those cases, as it was the case for #2108.