Avoid using Markdownify

In the step by step guide:

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

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.

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.

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.

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

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

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

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

The output html I want to acheive

<p>aaaaaa</p>
<p>bbbbbb</p>

So I put in front matter

someterm: "aaaaaa

bbbbbb"

What I get

<p>aaaaaabbbbbb</p>

The issue here is your YAML not the markdownify filter.

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

someterm: |
  aaaaa

  bbbbb

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

<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/

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