Skip to main content

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 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.0.tar.gz (3.2 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.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkdocs_publish_control-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 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.0.tar.gz
Algorithm Hash digest
SHA256 63121a421cb4f82f518c6e79a3c91250807b0f4790420ed626754db40c55766a
MD5 4aaa0521f699bd73bb8e3fcfc2a1bb5b
BLAKE2b-256 b6fdbbff20535eb4c052f729c53fbcf45dbcd68d8ed1ae1864795c9a7caa5f2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mkdocs_publish_control-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ea37c545688d9258bf972db5ca837021c41482c9fcaf507df7885ee2070bef2
MD5 ec1607cda9645b52258d8e5dde0bb4e7
BLAKE2b-256 96a6d2f93243e9ca317d06fd2f3ca5c94aa8839ac372a08e735d16704330a4ca

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