This Grav plugin let's you add additional markdown files to a page and make them available in your twig template as an array. This is very useful when you need to render complex components using markdown.

This plugin is deprecated and not maintained anymore. Please check out the new Gravstrap plugin.

Usually you would assign the content for each tab to an array defined in the page's header section, which is written in yaml format and it is not full compatible with markdown neither with HTML.

This plugin helps when you fall in this kind of situation.

Installation

To install this plugin, just download the last release from the Github repository where it is hosted, then unzip it under /your/site/grav/user/plugins. Next, rename the folder to markdownsections to complete the installation.

You should now have all the plugin files under

/your/site/grav/user/plugins/markdownsections

Updating

As development for the Markdown Sections plugin continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience.

Manual Update

Manually updating Markdown Sections is pretty simple. Here is what you will need to do to get this done:

  • Delete the your/site/user/plugins/markdownsections directory.
  • Downalod the new version of the Markdown Sections plugin from either GitHub.
  • Unzip the zip file in your/site/user/plugins and rename the resulting folder to markdownsections.
  • Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing bin/grav clear-cache.

Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in user/config/plugins) will remain intact.

Usage

You need to Just add one or more files with the markdown extension into the folder that defines the page where sections will be rendered.

Please note that the markdown extended extension name has been chosen to avoid confusion with the default md page extension.

Next, you will add two or more sections to that file, as follows:

[SECTION Section 1]

**Markdown content** goes here

[/SECTION]

[SECTION Section 2]

Another `awesome` markdown content

[/SECTION]

Here there are two sections, one called Section 1 and another one called Section 2.

Supposing the sections file is named sections.markdown, in your template you can render those sections as follow:

{{ sections["page"]["sections.markdown"]["Section 1"] }}
{{ sections["page"]["sections.markdown"]["Section 2"] }}

The Markdown sections plugin also parses modular pages modules. In that case, you can render a section contained into a specific module as follows:

{{ sections["modular"][MODULE NAME]["sections.markdown"]["Section 1"] }}