Jekyll post.content output is surrounded by <p> tag

Maybe you could check this answer: Use a <div> to wrap content

I tried and it does work. Probably there's a better way, but I haven't been able to figure it out yet.


Jekyll automatically wraps content in p tags. You can remove those tags with a liquid command. Per Jekyll's documentation:

Because Jekyll grabs the first paragraph you will not need to wrap the excerpt in p tags, which is already done for you. These tags can be removed with the following if you’d prefer:

{{ post.excerpt | remove: '<p>' | remove: '</p>' }}

Hope this helps!


To output whole pages without the <p> tags, such as to output a .txt or .json file, create a new layout file (e.g. "_layouts/plaintext.html") with this as the entire content:

{{ content | remove: "<p>" | remove: "</p>" }}

Then call the layout in the header of relevant files, like:

---
permalink: sample.json
layout: plaintext
---

I changed the post file's extension from .md to plain old .html

Tags:

Liquid

Jekyll