Skip to main content

MkDocs plugin to control page publishing based on metadata

Project description

MkDocs Publish Control

PyPI version Test Coverage License

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 hidden metadata flag.
  • Override visibility settings using environment variables.
  • Works with both mkdocs serve and mkdocs 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: true is set, the page will be excluded from the build
  • If hidden: false is 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:

  1. Using environment variable:
MKDOCS_SHOW_ALL=true mkdocs serve
  1. 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

  1. Create a markdown file with hidden metadata:
---
hidden: true
---

# Draft Content
This page will not appear in the build by default.
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_publish_control-0.1.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_publish_control-0.1.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_publish_control-0.1.2.tar.gz.

File metadata

  • Download URL: mkdocs_publish_control-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 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

Hashes for mkdocs_publish_control-0.1.2.tar.gz
Algorithm Hash digest
SHA256 12bd638b4b9f6e3e6ec036a3950c87bf393aa5bff4fafab507ab2d81bc90c35a
MD5 71a80033a47ddda3f1b17c048109cf2f
BLAKE2b-256 f0079485571923c51743abb9093fe73acc7108a6f89b44c347e7d3ac1ee4fd8a

See more details on using hashes here.

File details

Details for the file mkdocs_publish_control-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_publish_control-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 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

Hashes for mkdocs_publish_control-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50fb23e5e9b061db96faf4f6df1037be35eec69109dd22926868be095ab7f4ca
MD5 65cf76b11742a52cf6b2298f031d414a
BLAKE2b-256 de850b407bbf02d1aca6349d295a8b472f3da423842b58d49cc28ef0da662182

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page