MkDocs Print Site Plugin
The mkdocs-print-site-plugin is an MkDocs plugin designed to combine all documentation pages into a single, printable HTML page. This allows for easy export to PDF and creates a standalone HTML file, useful for offline viewing or comprehensive sharing. It is actively maintained with frequent updates, currently at version 2.8.
Common errors
-
Plugin 'print-site' is not found
cause The plugin has not been installed or its name is misspelled in the `mkdocs.yml` configuration.fixRun `pip install mkdocs-print-site-plugin` to install the package and ensure `print-site` is correctly listed under the `plugins:` section in your `mkdocs.yml`. -
ERROR - Config value 'plugins' must be a list of strings or dicts
cause The `print-site` plugin is not configured correctly in `mkdocs.yml`, often due to incorrect YAML indentation or improper list formatting under `plugins:`.fixEnsure `print-site` is an item in a YAML list under `plugins:`, for example: ```yaml plugins: - print-site ``` -
ERROR - The 'print-site' plugin encountered an error: 'NoneType' object has no attribute 'h1'
cause A page in your documentation is missing an H1 heading, and you are using a version of the plugin older than v2.5.0 which required all pages to have an H1.fixUpgrade `mkdocs-print-site-plugin` to v2.5.0 or newer. Alternatively, ensure all documentation pages have at least one H1 heading. -
WARNING - Plugin 'print-site' has already been loaded from '<some_path>'. Ignoring new instance from '<another_path>'.
cause The `print-site` plugin is listed multiple times in the `plugins` section of your `mkdocs.yml` file.fixReview your `mkdocs.yml` and remove any duplicate entries for `print-site` from the `plugins` list.
Warnings
- breaking Prior to v2.3.6, the plugin could break with MkDocs 1.5 due to changes in how `extra_javascript` was handled, leading to build failures or incorrect script loading.
- gotcha Before version 2.5.0, pages without an H1 heading would cause an error during site generation. This was a common footgun for users with less structured pages.
- gotcha While often flexible, for some MkDocs hooks or other plugins, the order of `print-site` in the `plugins` list could lead to unexpected behavior or warnings. v2.6.0 addressed invalid warnings, but complex setups might still require careful ordering.
- gotcha Prior to v2.7.1, the `exclude()` function in the plugin configuration might not correctly deal with excluding entire folders, leading to unwanted pages appearing in the print output.
Install
-
pip install mkdocs-print-site-plugin
Quickstart
site_name: My Docs plugins: - print-site