# Avoid using Markdownify

**URL:** <https://talk.jekyllrb.com/t/avoid-using-markdownify/4530>\
**Category:** Help\
**Created:** [June 3, 2020, 10:46pm UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530 "2020-06-03T22:46:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AceBerry](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@AceBerry](https://talk.jekyllrb.com/u/AceBerry)\
**Post date:** [June 3, 2020, 10:46pm UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/1 "2020-06-03T22:46:19Z")

</div>

In the step by step guide:

> **[Collections](https://jekyllrb.com/docs/step-by-step/09-collections/)**
>
> Let’s look at fleshing out authors so each author has their own page with a blurb and the posts they’ve published.

it says that the filter markdownify is necessary when not using {{content}} in a layout. Also in the filter guide:

> **[Liquid Filters](https://jekyllrb.com/docs/liquid/filters/)**
>
> All of the standard Liquid filters are supported (see below).

it says it is used to convert markdown code into html.

But I had some doubts about the effectiveness of this command because I tried to remove it from {{file.content | markdownify }} and it would render it anyways.

Moreover I also wanted to share with you another issue I solved by removing this filter.

I had a layout with some katex formulas rendering scripts. I needed them because inside this layout I would include a .md file with some katex formulas. I would include this file though the Liquid command {{file.content | markdownify}}. The fact is that with markdownify it wouldn’t render the formulas whilst it would do it as soon as I would cancel it.

---

<div class="post-metadata">

**Author:** ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)\
**Post date:** [June 4, 2020, 7:13am UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/2 "2020-06-04T07:13:34Z")

</div>

The primary indication to use the `markdownify` filter is when processing text that wouldn’t otherwise be parsed as Markdown and then converted into HTML.

For example, say you a source file named `about.html` instead of `about.markdown` or `about.md`. Since the extension is `.html`, it will not be processed by Kramdown or any other Markdown processor. So if you have any Markdown content in `about.html`, either directly or via the front matter, it will not be converted to HTML unless you use the `markdownify` filter.

Another scenario is using Markdown data in HTML layouts. If you have  
`{{ site.description | markdownify }}`, then the `description` key in your config file could point to a Markdown text and it will be rendered as HTML.

---

<div class="post-metadata">

**Author:** ![Koos](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@Koos](https://talk.jekyllrb.com/u/Koos)\
**Post date:** [August 7, 2020, 2:24pm UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/3 "2020-08-07T14:24:10Z")

</div>

I use `markdownify` a lot in combination with custom front matter variables. Some of my templates have differently designed sections with specific headings and subheadings. I define those in front matter and use `markdownify` to get things like proper paragraphs, `<strong>` and `<em>` in the body text.

---

<div class="post-metadata">

**Author:** ![MichaelCurrin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelcurrin/32/2340_2.png) [@MichaelCurrin](https://talk.jekyllrb.com/u/MichaelCurrin)\
**Post date:** [August 10, 2020, 10:11pm UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/4 "2020-08-10T22:11:50Z")

</div>

Same for me. I have put a markdown snippet in quotes like a markdown image tag, then placed it in html file with markdownify to convert it.

I also have a data file of YAML format which has some md in it which becomes plain text when rendered unless I use markdownify. Similar case to the frontmatter comment

---

<div class="post-metadata">

**Author:** ![printf](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@printf](https://talk.jekyllrb.com/u/printf)\
**Post date:** [September 3, 2020, 5:24pm UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/5 "2020-09-03T17:24:25Z")

</div>

> [@Koos](#):
>
> I define those in front matter and use `markdownify` to get things like proper paragraphs, `<strong>` and `<em>` in the body text.

Would you please talk a little more? I’m trying to `markdownify` front matter items but it seems not work with paragraphs.

---

<div class="post-metadata">

**Author:** ![MichaelCurrin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelcurrin/32/2340_2.png) [@MichaelCurrin](https://talk.jekyllrb.com/u/MichaelCurrin)\
**Post date:** [September 4, 2020, 9:00pm UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/6 "2020-09-04T21:00:04Z")

</div>

Can you be more specific with what is not working?

If you have a multi line paragraph perhaps you need to replace line breaks with `<br>` tag

````auto
site.description | markdownify | newline_to_br
```

You can also try using two newline filters in a row. Or move markdownify to end.

Docs

https://shopify.dev/docs/themes/liquid/reference/filters/string-filters
````

---

<div class="post-metadata">

**Author:** ![printf](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@printf](https://talk.jekyllrb.com/u/printf)\
**Post date:** [September 5, 2020, 6:19am UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/7 "2020-09-05T06:19:01Z")

</div>

The output html I want to acheive

```auto
<p>aaaaaa</p>
<p>bbbbbb</p>

```

So I put in front matter

```auto
someterm: "aaaaaa

bbbbbb"

```

What I get

```auto
<p>aaaaaabbbbbb</p>

```

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [September 5, 2020, 2:18pm UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/8 "2020-09-05T14:18:13Z")

</div>

The issue here is your YAML not the `markdownify` filter.

Try this instead which uses a pipe to indicate how newlines are dealt with:

```auto
someterm: |
  aaaaa

  bbbbb

```

Then `{{ page.someterm | markdownify }}` will give you:

```auto
<p>aaaaa</p>
<p>bbbbb</p>

```

Check the YAML spec for or this page that has some good info and examples on the different types of block scalars available in YAML.

[https://yaml-multiline.info/](https://yaml-multiline.info/)

---

<div class="post-metadata">

**Author:** ![printf](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@printf](https://talk.jekyllrb.com/u/printf)\
**Post date:** [September 5, 2020, 2:23pm UTC](https://talk.jekyllrb.com/t/avoid-using-markdownify/4530/9 "2020-09-05T14:23:52Z")

</div>

Thank you so much! That’s what I need. I know too little about YAML to know where to start search.
