MkDocs Open In New Tab Plugin
mkdocs-open-in-new-tab is an MkDocs plugin designed to automatically open outgoing links and PDF files in a new browser tab. As of version 1.0.8, it provides stable functionality for enhancing user navigation in MkDocs-generated documentation sites. Releases are infrequent but stable, addressing key compatibility and feature needs.
Common errors
-
Plugin 'open-in-new-tab' not found.
cause The plugin is not installed, or there is a typo in the `mkdocs.yml` configuration.fixEnsure the plugin is installed (`pip install mkdocs-open-in-new-tab`) and that the `plugins` section in `mkdocs.yml` correctly lists `open-in-new-tab`. -
YAMLError: while scanning a simple key
cause The `mkdocs.yml` configuration file contains invalid YAML syntax (e.g., incorrect indentation, missing colons).fixCarefully check the indentation and syntax of your `mkdocs.yml` file, especially around the `plugins` section. YAML is sensitive to whitespace. -
ModuleNotFoundError: No module named 'mkdocs_open_in_new_tab'
cause Attempting to import the plugin directly in Python code. MkDocs plugins are not meant to be imported this way.fixMkDocs plugins are configured in `mkdocs.yml`. Remove any Python `import` statements for `mkdocs_open_in_new_tab` and ensure it's correctly listed under the `plugins` section in your `mkdocs.yml`.
Warnings
- gotcha Ensure MkDocs is installed and accessible in your environment. As a plugin, it relies on MkDocs to run and generate documentation.
- gotcha Versions prior to 1.0.3 had a known issue where they could interfere with MkDocs' instant loading feature, causing navigation problems.
- gotcha Incorrectly configuring `external_only` or `pdf_only` can lead to unexpected link behavior. For instance, setting `external_only: false` will make *all* links (internal and external) open in new tabs, which might not be desired.
Install
-
pip install mkdocs-open-in-new-tab
Imports
- open-in-new-tab
plugins: - mkdocs_open_in_new_tab
plugins: - open-in-new-tab
Quickstart
site_name: My Docs
plugins:
- open-in-new-tab:
external_only: true # Only open external links in new tabs
pdf_only: false # Do not open PDF links in new tabs