markdownjekyllyaml-front-matter

markdownify post title in jekyll


It is possible to render Markdown on a post title? For example:

---
title: Foo and _other foo_
---

I want that output

<h1> Foo and <i>other foo</i></h1>

Solution

  • Use the markdownify filter to the Liquid tag:

    {{ page.title | markdownify }}
    

    Note that this will wrap the output in paragraph tags (<p> ... </p>). If this is not desired (which it probably isn't), you can remove these with Liquid:

    {{ page.title | markdownify | remove: '<p>' | remove: '</p>' }}
    

    There have been attempts to fix markdownify to work with titles so that paragraph tag wrapping doesn't happen, but they haven't materialized and so this clumsy solution is what's available for now. If you'd like to work on it your help would be appreciated!