Skip to content

Allow docs to be in the root directory#3519

Draft
oprypin wants to merge 3 commits intomasterfrom
same
Draft

Allow docs to be in the root directory#3519
oprypin wants to merge 3 commits intomasterfrom
same

Conversation

@oprypin
Copy link
Copy Markdown

@oprypin oprypin commented Dec 15, 2023

If the config file is inside docs_dir, you get this message:

ERROR   -  Config value 'docs_dir': The 'mkdocs.yml' config file should not be inside the docs_dir.
           To allow this arrangement, please exclude the file (and other files as applicable) by adding the following configuration:

           exclude_docs: |
             /mkdocs.yml

If the site_dir is inside docs_dir, you get this message:

ERROR   -  Config value 'site_dir': The site_dir should not be inside the docs_dir as this leads to the build directory being copied into itself.
           To allow this arrangement, please exclude the directory (and other files as applicable) by adding the following configuration:

           exclude_docs: |
             /site

Oleh Prypin added 3 commits December 15, 2023 13:54
Fix bypassing it when:

* a non-absolute config_file_path is passed on the command line
* the directory is not an *exact* parent of the other one, but is instead a "grandparent".

Also validate it in `mkdocs serve` because why reserve the check only to `mkdocs build`.
@oprypin

This comment was marked as abuse.

@athackst
Copy link
Copy Markdown
Contributor

I think the site_dir message is good.

I'm not sure I follow what use case you're protecting against to warn against the mkdocs.yml file inside of the docs dir.

Previously mkdocs required the docs dir to be located in a child directory named 'docs', but since you can now specify the config from the command line, I don't believe this is the case any more?

@oprypin

This comment was marked as abuse.

@athackst
Copy link
Copy Markdown
Contributor

Ah, ok. Makes sense then.

@athackst
Copy link
Copy Markdown
Contributor

Would you consider making it a warning instead of an error?

@oprypin

This comment was marked as abuse.

@athackst
Copy link
Copy Markdown
Contributor

Yeah, if you want to do something like #3526 so excluded docs aren't triggering the reload server but you want to have mkdocs.yml trigger it, you might want to not add it to exclude_docs

@athackst
Copy link
Copy Markdown
Contributor

Eh, nevermind. I think I found a clean way of handling that case. An error sounds fine to me.

@oprypin

This comment was marked as abuse.

@athackst
Copy link
Copy Markdown
Contributor

Who are the next maintainers?

@pawamoy
Copy link
Copy Markdown
Contributor

pawamoy commented Apr 21, 2024

Right now, they are the people in the @mkdocs/core team who have the time and will to work on MkDocs :) As you know it, we're also trying to onboard more people.

@oprypin

This comment was marked as abuse.

@dannyhanford
Copy link
Copy Markdown

Would love this to be picked up and merged.

I want to keep docs in the root directory so github displays it.

@athackst
Copy link
Copy Markdown
Contributor

Is there any additional features/feedback needed for this to merge? I can help update on the code side if needed

@anb0s
Copy link
Copy Markdown

anb0s commented Jul 29, 2025

It would be great to support this in mkdocs replacing the plugin mkdocs-same-dir and also fix compatibility with mkdocs-awesome-nav.

I can help with adapting and testing this.

Any update from maintainers if it makes sense to proceed or some alternative way?

/cc @nihalshah-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants