Skip to content

Commit b8645db

Browse files
NetdocsCopilot
andcommitted
Document .mkdocsignore path exclusion in file-filter plugin
Explain that `.mkdocsignore` prunes whole sections and follows the same `enabled` gate as label filtering, so dev-only areas stay visible during development/serve and are hidden only in production. Note the gitignore-like fallback when no `.file-filter.yml` is present. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4680e9f commit b8645db

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

docs-site/docs/plugins/file-filter.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ enabled_on_serve: true
2222
# Front-matter property that holds the labels.
2323
metadata_property: labels
2424

25+
# Path-based exclusion via a .mkdocsignore file (see below).
26+
mkdocsignore: true
27+
mkdocsignore_file: .mkdocsignore
28+
2529
# Pages with any of these labels are excluded…
2630
exclude_tag:
2731
- draft
@@ -44,13 +48,37 @@ labels:
4448
This page is excluded when the filter is active.
4549
```
4650

51+
## Path exclusion with `.mkdocsignore`
52+
53+
For whole sections you don't want in production, list their paths in a **`.mkdocsignore`**
54+
at the project root (same glob style as `.gitignore`):
55+
56+
```text title=".mkdocsignore"
57+
# Dev-only areas — present locally, hidden in production
58+
internal-notes/
59+
teams/
60+
```
61+
62+
Path exclusion follows the **same `enabled` gate** as label filtering, so those sections
63+
stay visible during development / `serve` and disappear only from production builds. The
64+
filter turns on when `enabled` resolves true — drive it from a build flag, e.g.
65+
`enabled: !ENV [MKDOCS_PROD_BUILD, false]` (Netdocs sets `MKDOCS_PROD_BUILD=true` on
66+
`--prod`).
67+
68+
!!! note "No `.file-filter.yml`?"
69+
If you have a `.mkdocsignore` but **no** `.file-filter.yml`, the ignore file is always
70+
applied (like `.gitignore`). The gate only exists once you opt into the filter.
71+
4772
## Behaviour
4873

4974
- The filter is **active** when `enabled` is true (on `serve`, `enabled_on_serve` must
5075
also be true).
76+
- While active, `.mkdocsignore` paths are pruned from discovery; while inactive they are
77+
kept, so dev-only sections reappear on non-production builds.
5178
- An **include** label always keeps a page.
5279
- Otherwise, any **exclude** label prunes the page from discovery and navigation.
53-
- If no `exclude_tag` values are configured, the filter is a no-op.
80+
- If no `exclude_tag` values are configured, the **label** filter is a no-op (path
81+
exclusion via `.mkdocsignore` still applies when active).
5482

5583
## Enabling the plugin
5684

0 commit comments

Comments
 (0)