Paragraph in data

How do I add paragraphs in data?

text : |
    This is the first paragraph.
    And this should be another.

I want it to render as:

<p>This is the first paragraph.</p><p>And this should be another.</p>

Does this help

1 Like

In your template:

<p>{{ .Site.Params.text | markdownify }}</p>

This assumes the param is coming from the config file. If instead it is coming from the content front matter, use .Params.text


Edit: I misunderstood what you were asking… If I’m understanding you correctly now, if your page’s front matter looks like this:

---
text: |
  <p>This is the first paragraph.</p>
  <p>And this should be another.</p>
---

Then you can do this in your template:

{{ .Params.text | safeHTML }}

This is how I do it:

text: '
first paragraph text


second paragraph text
'

Essentially, I use a double line break, and markdownify the output.

1 Like