Registry / web-framework / mkdocs-include-markdown-plugin

mkdocs-include-markdown-plugin

JSON →
library7.3.0pypypi✓ verified 22d ago

The mkdocs-include-markdown-plugin enhances MkDocs by allowing users to include content from other Markdown files, or parts of files, directly into their pages. It supports various features like fragment inclusion, heading offset, and line ranges. The current version is 7.2.2, with active development and frequent minor releases.

pip install mkdocs-include-markdown-plugin
INSTALL
IMPORT
SIG · MKDOCS-INCLUDE-MAR
M
mkdocs-include-markdown-plugin
web-frameworkpythonv7.3.0
Install
3.3s avg
Import
631ms
Disk
33MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v7.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.638s · 33.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.3s · import 0.624s · 35MB
33MB installed
● package 33MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

IncludeMarkdownPlugin
from mkdocs_include_markdown_plugin.plugin import IncludeMarkdownPlugin
This is the internal Python class. For common usage, you enable the plugin via your 'mkdocs.yml' file, not via direct Python import.

To use the plugin, first install it. Then, enable it in your `mkdocs.yml` file under the `plugins` section. Create a Markdown file (e.g., `docs/index.md`) and use the `{!include path/to/file.md!}` syntax to embed content from another Markdown file (e.g., `docs/includes/snippet.md`).

# mkdocs.yml site_name: My Docs plugins: - include-markdown # docs/index.md # This is your main Markdown file --- # Welcome This is the main content of my document. Here's some content included from another file: {!include includes/snippet.md!} --- # docs/includes/snippet.md # This is the file to be included --- ## Included Section This text comes from 'includes/snippet.md'. It can contain any Markdown.
mkdocs --version
Debug
Known issues
gotchaThe plugin must be explicitly enabled in your `mkdocs.yml` file. If you forget to add `plugins: - include-markdown` (or similar for custom configuration), the `{!include ...!}` directives will not be processed and will appear as raw text in your output.
fix
Ensure `include-markdown` is listed under the `plugins` section in your `mkdocs.yml`.
affects: All versions
gotchaPaths specified in `{!include ...!}` directives are relative to the *current* Markdown file where the directive is used, not to the `docs` directory or the project root. Incorrect relative paths will lead to `FileNotFoundError`.
fix
Verify the relative path from the *parent* Markdown file to the *included* Markdown file. Use `.` for current directory, `..` for parent directory.
affects: All versions
gotchaThe plugin uses `{!include ...!}` syntax for inclusion. This is distinct from Jinja2-style `{{ include ... }}`. Mixing these or using incorrect syntax will prevent content from being included.
fix
Always use the `{!include ...!}` syntax provided by the plugin for directives. Be mindful of potential conflicts if other plugins or themes also use similar curly bracket syntax.
affects: All versions
gotchaThe `heading-offset` argument (e.g., `{!include file.md:heading-offset=1!}`) applies a numeric offset to all headings within the included content. Incorrectly specifying or misunderstanding the offset can lead to unintended heading levels in the final output. While a bug with negative values was fixed in v7.1.7, ensure offsets are logical for your document structure.
fix
Carefully test `heading-offset` values. A positive offset increases heading levels (e.g., `#` becomes `##`), while a negative offset decreases them. Use `0` for no change.
affects: <7.1.7 for negative values, All versions for general understanding.
Errors
Common errors & fixes
Plugin 'include-markdown' not found. Please make sure it is installed and enabled in your mkdocs.yml configuration.
The mkdocs-include-markdown-plugin is either not installed, or not correctly enabled in the `mkdocs.yml` configuration file.
fix
First, ensure the plugin is installed: `pip install mkdocs-include-markdown-plugin`. Then, add or verify its entry in `mkdocs.yml` under the `plugins` section:
```yaml
plugins:
  - include-markdown
```
ERROR - Error reading page 'your_page.md': Encountered unknown tag 'some_tag'.
MkDocs is trying to interpret a Jinja2-like tag (`{% ... %}`) in your Markdown file as a plugin directive, but it's not a valid directive or it's meant to be plain text.
fix
If the tag is not intended to be processed by the plugin, escape it using Jinja2's `{% raw %}` and `{% endraw %}` tags to treat its content as literal text:
```markdown
{% raw %}{% some_tag %}{% endraw %}
```
ERROR - No files found including '../path/to/file.md' at your_page.md:line_number.
The path provided in the `include-markdown` directive is incorrect or the target file does not exist at the specified relative or absolute location.
fix
Verify the file path. Paths can be relative to the current Markdown file, relative to the `docs_dir`, or absolute. Ensure the file exists and the path is correctly specified, including any necessary `../` for parent directories.
The `include-markdown` directive is displayed verbatim in the output (e.g., `{% include-markdown "file.md" %}` instead of the included content).
The plugin is not processing the include directive, often due to a conflict with another plugin (like `mkdocs-material`'s `offline` plugin in some versions) or an issue in the MkDocs build process preventing plugin execution.
fix
Check for plugin conflicts, especially with `mkdocs-material`'s `offline` plugin (which had known issues). Ensure `mkdocs-include-markdown-plugin` is listed correctly in `mkdocs.yml`. If documenting the directive itself, place the example within a fenced code block (```markdown ... ```) which the plugin is designed to skip.
Upgrade
Version history
7.3.0latest on PyPI · released May 15, 2026
Audit
Dependencies
mkdocsrequiredCore dependency for MkDocs documentation generation.
markdownrequiredCore dependency for Markdown parsing.
watchdogoptionalOptional dependency to enable auto-reloading during development with the MkDocs dev server.
platformdirsoptionalOptional dependency for configuring the HTTP cache directory when using 'cache_dir' global setting.
Agent activity
6 hits · last 30 days
node
4
Bingbot
1
Resources
mkdocs-include-markdown-plugin — pip install mkdocs-include-markdown-plugin · libregistry