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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

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

Hashes for mkdocs_pages_j2_plugin-0.3.1.tar.gz
Algorithm Hash digest
SHA256 fe69d54d831046c3ad1ae4fd8f686d835014271c5a785b7b9acf65da1348e4f9
MD5 66ee5160108473e7115792a627acd464
BLAKE2b-256 4b95ee264313670cf085966ff87f38b85834f5e11d596993b762a33a082f8af6

See more details on using hashes here.

File details

Details for the file mkdocs_pages_j2_plugin-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_pages_j2_plugin-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efa0789b15870360eb61a9eac72bf5d48f99f98e03d6c921db114078d8428ac4
MD5 a9cd8534c43b0df48b3c69dd72c7a0cf
BLAKE2b-256 9d7cc5daa2128eda784b1f5fe05979b8f8bb26ce6416c3e42ee8b2a9413ef115

See more details on using hashes here.

Supported by

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