Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll: Cannot render YAML front matter field as markdown correctly

I am building the pages in my site with a list of nodes in the YAML front matter, like so:

---
title: My page
layout: default
nodes:
  - header: Node header
    text_block: >
        This is supposed to be markdown.

        [This works](http://example.com)

        But:  
        - this
        - doesn't
        - work
---

And then:

{% for node in page.nodes %}
    {{ node.text_block | markdownify }}
{% endfor %}

In the above example, the text_block will be rendered like this:

This is supposed to be markdown. This works But: - this - doesn't - work

The line breaks and lists are not being rendered, it's all just put together in one big <p> tag.

Changing rendering engine to redcarpet doesn't work, and neither does adding unindent to the markdownify call

Something tells me this has to do with the indentation level, but I just can't work it out.

like image 245
mrzapp Avatar asked Jan 24 '26 10:01

mrzapp


1 Answers

I found the problem, it was YAML related. Instead of using > in the beginning of the field, I used |, and it solved the problem.

like image 91
mrzapp Avatar answered Jan 27 '26 01:01

mrzapp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!