# 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](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin).
## Installation
Install the package with pip:
```bash
pip install mkdocs-pages-j2-plugin
```
Activate the plugin in `mkdocs.yml`:
```yaml
plugins:
- search
- pages-j2
- awesome-pages
```
## Configuration
The plugin can be configured in the `plugins` section of `mkdocs.yml` as follows:
```yaml
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:
```jinja2
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:
```text
title: Page Title
nav:
- Welcome: index.md
- My Page 1: p1.md
- My Page 2: p2.md
```
Raw data
{
"_id": null,
"home_page": "https://github.com/supcik/mkdocs-pages-j2-plugin",
"name": "mkdocs-pages-j2-plugin",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "mkdocs,python,markdown,wiki",
"author": "Jacques Supcik",
"author_email": "jacques.supcik@hefr.ch",
"download_url": "https://files.pythonhosted.org/packages/4b/95/ee264313670cf085966ff87f38b85834f5e11d596993b762a33a082f8af6/mkdocs_pages_j2_plugin-0.3.1.tar.gz",
"platform": null,
"description": "# mkdocs-pages-j2-plugin\n\nThis plugin builds `.pages` files from `.pages.j2` files, using Jinja2 to render the templates.\nThis plugin is particularly useful when used together with the\n[mkdocs-awesome-pages-plugin](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin).\n\n## Installation\n\nInstall the package with pip:\n\n```bash\npip install mkdocs-pages-j2-plugin\n```\n\nActivate the plugin in `mkdocs.yml`:\n\n```yaml\nplugins:\n - search\n - pages-j2\n - awesome-pages\n```\n\n## Configuration\n\nThe plugin can be configured in the `plugins` section of `mkdocs.yml` as follows:\n\n```yaml\nplugins:\n ...\n - pages-j2:\n use_extra: true\n ...\n```\n\nIf `use_extra` is set to `true` (the default), the plugin will use the `extra` section of `mkdocs.yml` as context for\nrendering the templates. Otherwise, the plugin will use the full configuration.\n\n**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.**\n\n## Usage\n\nExample of a `.pages.j2` file:\n\n```jinja2\ntitle: Page Title\nnav:\n - Welcome: index.md\n{%- for i in range(1,3) %}\n - My Page {{ i }}: p{{ i }}.md\n{%- endfor %}\n```\n\nThe plugin will render the _Jinja2_ template above and create a `.pages` file with the following content:\n\n```text\ntitle: Page Title\nnav:\n - Welcome: index.md\n - My Page 1: p1.md\n - My Page 2: p2.md\n```\n\n",
"bugtrack_url": null,
"license": "Apache-2",
"summary": "An MkDocs plugin to generate '.pages' from 'pages.j2'",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/supcik/mkdocs-pages-j2-plugin",
"Repository": "https://github.com/supcik/mkdocs-pages-j2-plugin"
},
"split_keywords": [
"mkdocs",
"python",
"markdown",
"wiki"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9d7cc5daa2128eda784b1f5fe05979b8f8bb26ce6416c3e42ee8b2a9413ef115",
"md5": "a9cd8534c43b0df48b3c69dd72c7a0cf",
"sha256": "efa0789b15870360eb61a9eac72bf5d48f99f98e03d6c921db114078d8428ac4"
},
"downloads": -1,
"filename": "mkdocs_pages_j2_plugin-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a9cd8534c43b0df48b3c69dd72c7a0cf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 3445,
"upload_time": "2024-02-13T21:40:35",
"upload_time_iso_8601": "2024-02-13T21:40:35.345283Z",
"url": "https://files.pythonhosted.org/packages/9d/7c/c5daa2128eda784b1f5fe05979b8f8bb26ce6416c3e42ee8b2a9413ef115/mkdocs_pages_j2_plugin-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4b95ee264313670cf085966ff87f38b85834f5e11d596993b762a33a082f8af6",
"md5": "66ee5160108473e7115792a627acd464",
"sha256": "fe69d54d831046c3ad1ae4fd8f686d835014271c5a785b7b9acf65da1348e4f9"
},
"downloads": -1,
"filename": "mkdocs_pages_j2_plugin-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "66ee5160108473e7115792a627acd464",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 2863,
"upload_time": "2024-02-13T21:40:37",
"upload_time_iso_8601": "2024-02-13T21:40:37.255699Z",
"url": "https://files.pythonhosted.org/packages/4b/95/ee264313670cf085966ff87f38b85834f5e11d596993b762a33a082f8af6/mkdocs_pages_j2_plugin-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-13 21:40:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "supcik",
"github_project": "mkdocs-pages-j2-plugin",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mkdocs-pages-j2-plugin"
}