An MkDocs plugin to generate '.pages' from 'pages.j2'
Project description
mkdocs-pages-j2-plugin
This plugin builds .pages files from .pages.j2 files, using Jinja2 to render the templates.
This plugin is particularly useful when used together with the
mkdocs-awesome-pages-plugin.
Installation
Install the package with pip:
pip install mkdocs-pages-j2-plugin
Activate the plugin in mkdocs.yml:
plugins:
- search
- pages-j2
- awesome-pages
Configuration
The plugin can be configured in the plugins section of mkdocs.yml as follows:
plugins:
...
- pages-j2:
use_extra: true
...
If use_extra is set to true (the default), the plugin will use the extra section of mkdocs.yml as context for
rendering the templates. Otherwise, the plugin will use the full configuration.
Note that this feature has been added in version 0.3.0 and is a breaking change from version 0.2.x. Set use_extra to false if you want the same behaviour as in pre 0.3.0 versions.
Usage
Example of a .pages.j2 file:
title: Page Title
nav:
- Welcome: index.md
{%- for i in range(1,3) %}
- My Page {{ i }}: p{{ i }}.md
{%- endfor %}
The plugin will render the Jinja2 template above and create a .pages file with the following content:
title: Page Title
nav:
- Welcome: index.md
- My Page 1: p1.md
- My Page 2: p2.md
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_pages_j2_plugin-0.3.1.tar.gz.
File metadata
- Download URL: mkdocs_pages_j2_plugin-0.3.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe69d54d831046c3ad1ae4fd8f686d835014271c5a785b7b9acf65da1348e4f9
|
|
| MD5 |
66ee5160108473e7115792a627acd464
|
|
| BLAKE2b-256 |
4b95ee264313670cf085966ff87f38b85834f5e11d596993b762a33a082f8af6
|
File details
Details for the file mkdocs_pages_j2_plugin-0.3.1-py3-none-any.whl.
File metadata
- Download URL: mkdocs_pages_j2_plugin-0.3.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efa0789b15870360eb61a9eac72bf5d48f99f98e03d6c921db114078d8428ac4
|
|
| MD5 |
a9cd8534c43b0df48b3c69dd72c7a0cf
|
|
| BLAKE2b-256 |
9d7cc5daa2128eda784b1f5fe05979b8f8bb26ce6416c3e42ee8b2a9413ef115
|