-
-
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
New exclude_docs
config: gitignore-like patterns of files to exclude
#3224
Conversation
I'm wondering, maybe for the sake of plugins it would be better to keep these files in the |
Yet another idea I just had- for the sake of writing drafts, these pages would still be shown in |
That would be really useful indeed. I wonder if the corresponding nav entry for a given excluded file/page should also be removed when building, because when I write something for my blog I have to comment/uncomment the post in the nav until it's ready. |
This reverts commit 4e0429e.
These files will not be picked up into the `Files` collection and as such, also the final built site. Also adds the ability to *un*-ignore the files that MkDocs forcibly ignores.
* Docs that match any of the `not_in_nav` patterns will not produce warnings about never being included into the nav. * Files that are excluded by `exclude_docs` will now be preserved in the `Files` collection and will even be rendered but only in `mkdocs serve` mode - such files will have a `DRAFT` notice prepended to the content.
…then serve Also rename `--dirtyreload` flag to `--dirty` (keep the old name working)
I have made the changes from both ideas that I described. See docs in the diff. If people could try out this code and see if it satisfies their wishes, that would be nice. pip install git+https://github.com/mkdocs/mkdocs.git@refs/pull/3224/head There's also the rather ugly matter of injecting raw HTML: mkdocs/mkdocs/commands/build.py Lines 218 to 223 in 89f15d9
The good thing is that all existing themes will support this out of the box (and still will be able to customize this if desired). If you have better ideas how to achieve this, do let me know. |
Seems to be working fine, thanks @oprypin 🙂 What's the reason for multiline strings instead of arrays for the config settings? |
|
If someone adds a doc to the nav but the doc will be excluded, I suspect that more people would find behavior [1] more intuitive, not sure why you prefer [2].
Imagine a situation where someone already has a wide exclude pattern but then forgets about it and really tries to add a file but nothing is happening (and they can even overlook this and push the site). @pawamoy Could you provide arguments for your case? |
Hmmm I think my main argument would be that such a feature would allow me to exclude a file and remove the corresponding nav entry automatically, until I'm ready to publish it, and in which case I either move the file around or stop excluding it. In short: exclude it once when you start working on it, re-include it once when you're ready. Without such a feature, I constantly have to comment/uncomment the nav entry in mkdocs.yml, at least if I publish other things while working on the draft. This is annoying but not critical. It's probably possible to write a plugin that does that. |
Hmm but you could just not add it to the nav until it's ready? And what about my counterargument? |
Yeah true, I guess I'm lazy and don't want to type the URL myself instead of clicking 🤔 I remember Jekyll had some first-class support for drafts. I'll check again how it works to see if there's something we can improve in MkDocs 🙂 |
Hmm that gives me an idea mkdocs/mkdocs/commands/build.py Lines 314 to 316 in 89f15d9
what if this message would proactively print the localhost URLs of the pages 😃 rather than just the path |
That would be nice yes :) |
And refactor `LiveReloadServer` to not start listening in the constructor
These files will not be picked up into the
Files
collection and as such, also the final built site.Also adds the ability to un-ignore the files that MkDocs forcibly ignores.