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)
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 + . |
1.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
Link Rewriting
Automatically update internal markdown links:
plugins:
- strip-number-prefix:
strip_links: true
Before:
[Setup Guide](020--setup.md)
After:
[Setup Guide](setup.md)
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
- MkDocs: >= 1.5.0
- Python: >= 3.9
- Works with:
- Material for MkDocs
- vexy-mkdocs-awesome-nav
- vexy-mkdocs-nav-weight
- Most other MkDocs plugins
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.md020--intro-advanced.md
Broken Links
When strip_links: false (default), use clean slugs in links:
✅ [Next page](configuration.md)
❌ [Next page](030--configuration.md)
When strip_links: true, both forms work:
✅ [Next page](configuration.md)
✅ [Next page](030--configuration.md) # Auto-converted
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:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 📖 Documentation: Project Documentation
Release files for vexy-mkdocs-strip-number-prefix 1.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vexy_mkdocs_strip_number_prefix-1.0.12.tar.gz | 15.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vexy_mkdocs_strip_number_prefix-1.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.5 kB
Release files / vexy_mkdocs_strip_number_prefix-1.0.12.tar.gz
| Download URL | vexy_mkdocs_strip_number_prefix-1.0.12.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f3cc8ba224d5c739e750c9ff83e3bfe915a8e6f7edb3a67a1d768790f6284d0
|
|
BLAKE2b-256 checksum How to use checksums |
6972b91460cf942dea2d76e4be46e1f5e01bbe71648564bec98ea4fde643a48e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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.12-py3-none-any.whl
| Download URL | vexy_mkdocs_strip_number_prefix-1.0.12-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c970da5b5914dbe884560bf54eeb07ea530edec5927e16da3cccf67de27010d0
|
|
BLAKE2b-256 checksum How to use checksums |
43868c7342c47ebb2961584ecd1c9e5c4946e7410478017e16971f6ebd9e5664
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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}
|