You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -181,6 +186,7 @@ The below table shows all supported options by the plugin.
181
186
# mkdocs.yml
182
187
plugins:
183
188
- file-filter:
189
+
filter_nav: true # default value
184
190
exclude_glob:
185
191
- 'drafts/**'
186
192
include_glob:
@@ -199,6 +205,7 @@ plugins:
199
205
# mkdocs.yml
200
206
plugins:
201
207
- file-filter:
208
+
filter_nav: true # default value
202
209
exclude_regex:
203
210
- '.*\.(tmp|bin|tar)$'
204
211
include_regex:
@@ -223,6 +230,7 @@ By default plugin filter files using `tags` property of your Markdown metadata.
223
230
# mkdocs.yml
224
231
plugins:
225
232
- file-filter:
233
+
filter_nav: true # default value
226
234
exclude_tag:
227
235
- abc
228
236
- draft
@@ -275,6 +283,7 @@ Set `metadata_property` with your custom list property, e.g., `labels` for this
275
283
# mkdocs.yml
276
284
plugins:
277
285
- file-filter:
286
+
filter_nav: true # default value
278
287
metadata_property: labels
279
288
exclude_tag:
280
289
- foo
@@ -336,8 +345,9 @@ Example config for mkdocsignore.
336
345
# mkdocs.yml
337
346
plugins:
338
347
- file-filter:
348
+
filter_nav: true # default value
339
349
mkdocsignore: true # default: false
340
-
mkdocsignore_file: 'custom/path/.myignore' # optional, relative to mkdocs.yml, default: .mkdocsignore
350
+
mkdocsignore_file: 'custom/path/.mkdocsignore' # optional, relative to mkdocs.yml, default: .mkdocsignore
341
351
```
342
352
343
353
Example `.mkdocsignore` file.
@@ -354,6 +364,59 @@ docs/**/draft-*.md
354
364
>
355
365
> **.mkdocsignore** patterns relative to your root.
356
366
367
+
### Navigation filtering
368
+
369
+
Suppose you customized [MkDocs navigation configuration][mkdocs-nav], and your `nav` contains elements defined in exclude patterns. In that case, the default MkDocs behavior is to render navigation to a non-existing file, and generated site gives 404.
370
+
371
+
By default, the plugin filters those cases and removes not working navigation items.
372
+
373
+
You can control the plugin's behavior to explicitly disable that option by setting `filter_nav: false`.
374
+
375
+
Example `mkdocs.yml` config.
376
+
377
+
```yaml
378
+
# mkdocs.yml
379
+
nav:
380
+
- Foo: exclude/this/path
381
+
- Bar: exclude/this/file/draft.md
382
+
- Abc:
383
+
- About: exclude/this/path/about.md
384
+
- Contact: include/this/file/contact.md
385
+
- Xyz: path/xyz.md
386
+
387
+
plugins:
388
+
- file-filter:
389
+
filter_nav: true # default value
390
+
exclude_glob:
391
+
- 'exclude/this/path/**'
392
+
- 'exclude/this/file/draft.md'
393
+
```
394
+
395
+
**Nav** results with `filter_nav: false`:
396
+
397
+
```yaml
398
+
- Foo: exclude/this/path # -> 404
399
+
- Bar: exclude/this/file/draft.md # -> 404
400
+
- Abc:
401
+
- About: exclude/this/path/about.md # -> 404
402
+
- Contact: include/this/file/contact.md
403
+
- Xyz: path/xyz.md
404
+
```
405
+
406
+
**Nav** results with `filter_nav: true`:
407
+
408
+
```yaml
409
+
- Abc:
410
+
- Contact: include/this/file/contact.md
411
+
- Xyz: path/xyz.md
412
+
```
413
+
414
+
> :warning: **NOTE**
415
+
>
416
+
> If you use any other 3rd-party plugins that modify navigation (e.g., [mkdocs-awesome-pages-plugin][mkdocs-awesome-pages-plugin-pypi]) - first, test and evaluate expected behavior. Plugin configuration order may impact results.
417
+
418
+
> In most cases is recommended to transform navigation first and next filter with the file-filter plugin.
419
+
357
420
### Conflict behavior
358
421
359
422
It is possible to exclude and include will have conflict. For example, you could exclude `drafts/**` but include `*.md`. In that case, **include** has higher priority over exclude. So all `*.md` files from the drafts folder will be **included**.
@@ -370,7 +433,9 @@ It is possible to exclude and include will have conflict. For example, you could
0 commit comments