Skip to main content

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

mkdocs_pages_j2_plugin-0.3.1.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

mkdocs_pages_j2_plugin-0.3.1-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page