-
-
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
mkdocs.yml location #1276
Comments
I thought this was discussed clearly elsewhere but I can't find it. However, there are some relevant (and lengthy) discussions in #543 and #610. Also, see #972, which was a bug encountered by a user because this policy was not always enforced as strictly as it is today. To answer the question directly, I'll point out that the root if a project often contains all sorts of config files ( However, there is much more to it than that, Its important to note the a MkDocs project can contain multiple items (including, but not limited to):
Within that narrow view, having the config file at the root makes sense. If you are really bothered by having the
In light of #543 (which may be subject to change), you do need to Finally, many of our competitors follow the same pattern. I realize that's not really a reason, but it shows a common pattern that many (most?) users will find natural. Given the above and the various other links issues, it should be clear that MkDocs has been created from its inception with the current behavior as the (in this regard) as the only way to configure the project. A change now would have far reaching consequences which would be a disruption to many many users. Therefore, even if reasonable counter-arguments could be made for each of the points above, there would have to be a pretty strong argument before we would consider such a change. |
Thanks for the reply. I think I'll go with the |
For future reference, there is one more consideration that I failed to mention earlier, which may actually be the most important one of all: Some of our competitors use various strict naming conventions for different things or require separate directories for documents verses assets, etc. In MkDocs, anything in the |
While these are valid considerations from a perfectionist standpoint (I can easily imagine myself being in that mindset), I think this is user-hostile, and is still a major factor in me doubting the choice of the tool.
Well no, that's what I really don't want. The files there describe my project, while mkdocs.yml describes a book I wrote for my project, and it should be with the book. Now, if I have multiple (kinds of) books, like the original poster, that structure just breaks down, and that's not coincidental but rather a natural consequence of mixing up these relations. Do I really want to see this unnecessary directory nesting just to isolate that one special snowflake of a file?
I'll still have to have that structure with 1 book anyway, because having the file at the top level just can't make sense considering the above. Or if I happened to use a different generator tool for that other doc, would I use this structure?
OK so I'll reconfigure that? Thankfully that option is not locked down.
I'm sure mkdocs.yml, which is already special in many regards, could easily be understood to also be special in that regard. This argument is still mainly perfectionism. Now what bothered me even more is just how adamant the tool is about enforcing this, even though it would've worked perfectly fine if not for the intentional error. There's no way to alter this validation step, no way to run something before it, or tell the tool "shh I know what I'm doing". No way for a plugin to achieve this, certainly, save for "hacking into" the implementation outside of the plugin API, e.g. mkdocs.config.config_options.Dir.post_validation = lambda *args, **kwargs: None Now, my main plan is to use a plugin that does just that, without publicizing it. I'll let my perfectionism run wild, except, of course, it won't be fully satisfied with that kind of solution. I would be thankful if you considered the possibility to let a plugin officially access this validation somehow, or access the config before the validation happens (this feature would make sense in general), or selectively suppress validation errors. |
@oprypin: I don't think this needs a plugin necessarily, this is how I got it to work: directory layout:
in mkdocs.yml:
as mkdocs is not aware of git anyway, for a publishing pipeline think of |
Add a line with name the dir in mkdocs.yml and create volume for material in docker using this command |
Using a symbolic works to resolve this issue.
|
@nmatare Yes, can confirm that. I'm currently using multiple symbolic links to generate a mkdocs based website (as a github page) just from within the main source repository. It works and processes are straight forward but it has some downsides that can be minimized by having this configuration on a specific branch. Example github page: https://ktomk.github.io/pipelines/ (the repo is linked in the header). |
While there might be some valid reasoning, I've hit a very simple problem with Docker. Just because
The suggested approach - In conclusion, my humble opinion is that there are no strong enough reasons to prohibit such a simple solution (also not sure how is this a breaking change, but I have not delved into details of implementation). |
@dzmitry-kankalovich Yes, and if you follow the link, for that scenario there is I do see the benefit you describe as well having the md files in the repository. In my case it's Github and before I started to integrate mkdocs it was I'm working with symbolic links (and one rename to have |
I had mentioned a plugin that I made that forces MkDocs to allow putting mkdocs.yml alongside the docs. |
@oprypin: Thank you very much for creating that plugin, it solves a long standing problem here! 👍 I dont't even mind having I tried hard to work around this issue using symlinks and all kinds of other approaches, but it seems mkdocs actually makes an effort to actively prevent them. I really like |
@dd-ssc I have no problems using symbolic links, even including the preview etc. with mkdocs, so I'm not aware of mkdocs actively preventing them, but your comment made me curious: can you elaborate more on the symbolic link prevention? |
mkdocs doesn't allow for root dir usage for docs reasoning explained mkdocs/mkdocs#1276
A workaround in case you are using docker compose:
|
you actually cannot have the mkdocs.yml as discussed by mkdocs here: mkdocs/mkdocs#1276 however, we can imitate that file structure within docker which makes the root and the folder structure both cleaner. Hence why we took that approach
my repo has multiple components, including:
I'd prefer to put my mkdocs.yml in my /docs dir. But I get this complaint:
I'm not sure I agree with this. What's the reasoning behind this?
The text was updated successfully, but these errors were encountered: