mkdocs-extrafiles is a lightweight MkDocs plugin that allows you to add files and directories from outside MkDocs document directory (docs_dir) to your MkDocs site build.
- Pull individual files or glob patterns from anywhere outside your
docs_dir. - Resolve relative paths against the MkDocs configuration directory.
- Create real source
Fileobjects at build time. - Automatically watch added sources during live reload (
mkdocs serve).
pip install mkdocs-extrafilesor, with astral-uv:
uv add mkdocs-extrafilesgit clone https://github.com/your-username/mkdocs-extrafiles.git
cd mkdocs-extrafiles
pip install .srcaccepts absolute paths or paths relative to the MkDocs config file.destaccepts relative paths to thedocs_dir; during a build they are created insite_dir.
Glob patterns (*, ?, []) require dest to end with / to indicate a directory target.
Enable the plugin and list the external sources inside mkdocs.yml:
plugins:
- search
- extrafiles:
files:
- src: README.md # file
dest: external/README.md
- src: LICENSE # file -> rename/relocate
dest: external/LICENSE.txt
- src: assets/** # glob (copies all matches)
dest: external/assets/ # must end with '/' to indicate a directorymkdocs serve: Sources are streamed directly; nothing is copied intodocs_dir, but live reload will watch the resolved absolute paths.mkdocs build: Virtual files are materialized intosite_dir, so deployments that publish only the build output still include the added sources.- Missing sources will result in a
FileNotFoundErrorexception.
If you are using mkdocs-gen-files then you must place extrafiles after mkdocs-gen-files in your plugin settings.
plugins:
- search
- gen-files:
scripts:
- gen_ref_pages.py
- extrafiles:
files:
- src: ../README.md
dest: extras/README.md- Package Manager:
uv - Language Server: Pylance
- Static Type Checker:
basedpyright - Linter: Ruff Linter
- Code Formatter: Ruff Formatter
Set up a development environment with uv:
uv sync --all-extras --all-groups
uv run pytest tests
uv run ruff check
uv run ruff format- Maintain 100% passing tests, at least 80% test coverage, formatting, and linting before opening a pull request.
- Update docstrings alongside code changes to keep the generated reference accurate.
Documentation is generated using MkDocs. The technical reference surfaces the reStructuredText style docstrings from the package's source code.
uv sync --group docs
# Run the development server
uv run mkdocs serve -f mkdocs/mkdocs.yaml
# Build the static site
uv run mkdocs build -f mkdocs/mkdocs.yamlContributions are welcome! To get started:
- Fork the repository and create a new branch.
- Install development dependencies (see the developer guide).
- Add or update tests together with your change.
- Run the full test, linting, and formatting suite locally.
- Submit a pull request describing your changes and referencing any relevant issues.
For major changes, open an issue first to discuss your proposal.
Distributed under the GNU General Public License v3.0. See LICENSE for details.
Questions or issues? Please open an issue on the repository's issue tracker.