MkDocs plugin to control page publishing based on metadata
Project description
MkDocs Publish Control
A MkDocs plugin that allows you to control page visibility based on metadata. Perfect for managing draft content or private documentation within your MkDocs site.
Features
- Control page visibility using simple metadata.
- Show/hide pages based on
hiddenmetadata flag. - Override visibility settings using environment variables.
- Works with both
mkdocs serveandmkdocs build. - Detailed logging for debugging.
Installation
Using Poetry
poetry add mkdocs-publish-control
Using pip
pip install mkdocs-publish-control
Usage
Basic Configuration
Add the plugin to your mkdocs.yml:
plugins:
- publish-control:
show_all: false # default behavior
Controlling Page Visibility
In your markdown files, add the hidden metadata at the top of the file:
---
hidden: true
---
# Your page content
- If
hidden: trueis set, the page will be excluded from the build - If
hidden: falseis set or the metadata is not present, the page will be included - The default behavior is to show pages (hidden: false)
Showing All Pages
You can override the visibility settings in two ways:
- Using environment variable:
MKDOCS_SHOW_ALL=true mkdocs serve
- Using configuration in
mkdocs.yml:
plugins:
- publish-control:
show_all: true
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | true |
Enable or disable the plugin |
show_all |
boolean | false |
Show all pages regardless of their hidden status |
Examples
Basic Usage
- Create a markdown file with hidden metadata:
---
hidden: true
---
# Draft Content
This page will not appear in the build by default.
- Run mkdocs:
mkdocs serve
The page will be excluded from the build.
Showing All Pages
To temporarily show all pages (including hidden ones):
MKDOCS_SHOW_ALL=true mkdocs serve
Or configure it permanently in mkdocs.yml:
plugins:
- publish-control:
show_all: true
Logging
The plugin provides detailed logging about which pages are being excluded. To see the logs, run mkdocs with the --verbose flag:
mkdocs serve --verbose
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_publish_control-0.1.1.tar.gz.
File metadata
- Download URL: mkdocs_publish_control-0.1.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.10.12 Linux/6.12.10-76061203-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdec61717a1a00e508ef82cb6f03fa9f17bfa360329c3dea66d9314733c7bb49
|
|
| MD5 |
2a09c02690b4c32504c3b51fe2a30cd1
|
|
| BLAKE2b-256 |
d244e4792e17d20c5a03a93d68e804bd32cf9fa9e522b206235568fa86532db9
|
File details
Details for the file mkdocs_publish_control-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mkdocs_publish_control-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.10.12 Linux/6.12.10-76061203-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6224610b1d33d3db2c0f1f062e3cdead523eddb84dc2cb60f25917419c8cdb0
|
|
| MD5 |
bb49aac2af0eaef563f645549cfadf8f
|
|
| BLAKE2b-256 |
3b269639521d4be7db920f99fe0ec77ae364eb55bed1992e109f81d1f7dc34a8
|