Markdown

The markdown helper renders Markdown content and is designed to be used in Markdown or HTML documents; it provides several ways to evaluate Markdown so we can seamlessly mix HTML and Markdown.

Arguments

Parameters

Example

The examples assume we have a snippet of Markdown in site/partials/snippet.hbs:

This is some *Markdown* content.

Then in a Markdown document these examples:

+++
content = "This is some *Markdown* content."
+++
<!-- Render a partial from the site/partials/snippet.hbs file -->
{{markdown snippet}}
<!-- Force render inside HTML content -->
<section class="section-style">
{{markdown snippet render=true}}
</section>
<!-- Render with an inner block template -->
{{#markdown}}This is some *Markdown* content.{{/markdown}}
<!-- Render using a string literal -->
{{markdown "This is some *Markdown* content."}}
<!-- Render a variable from the front matter -->
{{~markdown content}}

Renders to this markup:

<p>This is some <em>Markdown</em> content.</p>
<section class="section-style">
<p>This is some <em>Markdown</em> content.</p>
</section>
<p>This is some <em>Markdown</em> content.</p>
<p>This is some <em>Markdown</em> content.</p>
<p>This is some <em>Markdown</em> content.</p>

Render

This helper knows the file context so when you are in HTML files there is no need to use the render parameter:

<section class="section-style">
  {{markdown snippet}}
</section>
info

The only time you should use render is in HTML inside a Markdown document.

warn

Be careful using the block syntax {{#markdown}} in HTML documents as leading whitespace can be mistakenly interpreted as fenced code blocks.

Back to Helpers