Skip to main content

vexy-mkdocs-strip-number-prefix

PyPI version CI codecov License: MIT Python versions

Documentation: https://vexy.dev/vexy-mkdocs-strip-number-prefix/

A lightweight MkDocs plugin that strips numeric prefixes from page URLs while preserving them in source filenames for natural sorting.

Features

  • ✅ Clean URLs: Remove numeric prefixes from generated URLs
  • ✅ Natural Sorting: Keep prefixes in source files for predictable ordering
  • ✅ Collision Detection: Prevent duplicate URLs with configurable strictness
  • ✅ Link Rewriting: Automatically update internal markdown links
  • ✅ Flexible Patterns: Customize prefix matching with regex patterns
  • ✅ Debug Support: Verbose logging for troubleshooting

Installation

Install from PyPI:

uv pip install --system --upgrade vexy-mkdocs-strip-number-prefix

or from source:

pip install git+https://github.com/vexyart/vexy-mkdocs-strip-number-prefix

Quick Start

Add the plugin to your mkdocs.yml:

plugins:
  - search
  - strip-number-prefix

Name your files with numeric prefixes:

docs/
├── 010--introduction.md
├── 020--getting-started.md
├── 030--configuration.md
└── 999--faq.md

Build your site:

mkdocs build

Generated URLs will be clean:

  • /introduction/
  • /getting-started/
  • /configuration/
  • /faq/

Configuration

All configuration options with their defaults:

plugins:
  - strip-number-prefix:
      pattern: '^\d+--'     # Regex pattern for prefix (default: '^\d+--')
      verbose: false         # Enable debug logging (default: false)
      strict: true           # Fail on slug collisions (default: true)
      strip_links: false     # Strip prefixes from markdown links (default: false)
      strip_nav_titles: true # Strip prefixes from navigation titles (default: true)
      dry_run: false         # Log changes without applying them (default: false)

Pattern Examples

Pattern Matches Example
^\d+-- Any digits + -- 123--file.md
^\d{3}-- Exactly 3 digits + -- 001--file.md
^\d+- Any digits + - 42-file.md
^\d+_ Any digits + _ 01_file.md

Collision Handling

When multiple files would generate the same URL after prefix removal:

plugins:
  - strip-number-prefix:
      strict: true   # Fail build (recommended)
      # strict: false  # Log warning and continue

Automatically update internal markdown links:

plugins:
  - strip-number-prefix:
      strip_links: true

Before:

[Setup Guide](020--setup.md)

After:

[Setup Guide](setup.md)

Caution: MkDocs resolves links against the prefixed source filenames, so rewritten links are reported as "not found" and stay unresolved. In most projects, leave strip_links: false and link to 020--setup.md; MkDocs then writes the clean URL for you.

Examples

Basic Usage

# mkdocs.yml
site_name: My Documentation
plugins:
  - strip-number-prefix

With Material Theme

# mkdocs.yml
site_name: My Documentation
theme:
  name: material
  features:
    - navigation.instant
    - navigation.sections

plugins:
  - search
  - strip-number-prefix:
      pattern: '^\d{3}--'
      verbose: true

With Awesome Nav

# mkdocs.yml
site_name: My Documentation
plugins:
  - search
  - awesome-nav
  - strip-number-prefix:
      pattern: '^\d+--'
      strip_links: true

Custom Pattern

# mkdocs.yml
plugins:
  - strip-number-prefix:
      pattern: '^\d{2}_'  # Matches: 01_file.md, 99_file.md
      strict: false

File Organization Strategies

Sequential Numbering

docs/
├── 010--introduction.md
├── 020--installation.md
├── 030--configuration.md
├── 040--advanced.md
└── 999--troubleshooting.md

Hierarchical Numbering

docs/
├── 100--getting-started.md
├── 110--installation.md
├── 120--first-steps.md
├── 200--configuration.md
├── 210--basic-config.md
├── 220--advanced-config.md
└── 900--appendix.md

Category Prefixes

docs/
├── 01--intro/
│   ├── 010--overview.md
│   └── 020--quickstart.md
├── 02--guides/
│   ├── 010--setup.md
│   └── 020--deployment.md
└── 99--reference/
    └── 010--api.md

Compatibility

Troubleshooting

Duplicate URLs

ERROR: Multiple files would map to 'intro.md': 010--intro.md, 020--intro.md

Solution: Use unique base names:

  • 010--intro-basics.md
  • 020--intro-advanced.md

Link to the prefixed source filename. MkDocs resolves it to the clean URL:

✅ [Next page](030--configuration.md)
❌ [Next page](configuration.md)   # no source file has this name

Keep strip_links: false (the default). With strip_links: true the link is rewritten to the clean filename before MkDocs resolves it, and MkDocs reports "the target is not found among documentation files". See Links and navigation.

Debug Mode

Enable verbose logging:

plugins:
  - strip-number-prefix:
      verbose: true

This shows:

  • File transformations
  • URL mappings
  • Collision warnings
  • Link rewriting

Development

Setup

git clone https://github.com/vexyart/vexy-mkdocs-strip-number-prefix
cd vexy-mkdocs-strip-number-prefix
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .[dev]
pre-commit install

Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=mkdocs_strip_number_prefix --cov-report=html

# Run specific test
pytest tests/test_plugin.py::TestStripNumberPrefixPlugin::test_default_pattern

Code Quality

# Format and lint
black src tests
ruff check --fix src tests
mypy src

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

Metadata

Release files for vexy-mkdocs-strip-number-prefix 1.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vexy-mkdocs-strip-number-prefix 1.0.14
File Size Uploaded Provenance Actions
vexy_mkdocs_strip_number_prefix-1.0.14.tar.gz 17.0 kB Without provenance Details for vexy_mkdocs_strip_number_prefix-1.0.14.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vexy-mkdocs-strip-number-prefix 1.0.14
File Interpreter ABI Platform Actions
vexy_mkdocs_strip_number_prefix-1.0.14-py3-none-any.whl Python 3 none any Details for vexy_mkdocs_strip_number_prefix-1.0.14-py3-none-any.whl

Total release size: 27.3 kB

Release files / vexy_mkdocs_strip_number_prefix-1.0.14.tar.gz

Download URL vexy_mkdocs_strip_number_prefix-1.0.14.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
86ba1adf3ef7f9df4455e4b38a029187a6ce4a15e77876ffc7a5ea816876104f
BLAKE2b-256 checksum
How to use checksums
d74c6a5bf651e21e40dadf9650ab78b5e857a94d182420800b8e8879d986be86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / vexy_mkdocs_strip_number_prefix-1.0.14-py3-none-any.whl

Download URL vexy_mkdocs_strip_number_prefix-1.0.14-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9176886396b0da7badfc4b0e6c3829ac933503644bc02f7f476f8b2caccd430
BLAKE2b-256 checksum
How to use checksums
e55c8b4f836f2b678a1296fff9d427a238a4de90f748ef269492cdd2f7c6968f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for vexy-mkdocs-strip-number-prefix 1.0.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page