3
votes

I'm wanting to use Jekyll as a CMS essentially, so I would like to take the content from a post and display it in a specific area of my website.

{% for post in site.posts %}
    {{ post.content }}
 {% endfor %}

This displays all of the content from all of the posts, however I'd like to take content from one post at a time. I'm fairly new to Jekyll, so I'm not sure if i'm supposed to add YAML front matter into my posts and target them with a "for post in site with title_____" post.content" of sorts.

Thank you!!

2

2 Answers

3
votes

{% assign thepost = site.posts | where:"slug","post_slug" %}
{% for post in thepost %}
 {{ post.content }}
{% endfor %}

And on the post;

slug: post_slug

2
votes

I figured it out, sorry I posted prematurely.

The answer is add a category to your post with YAML front matter and then in your include file use:

{% for post in site.categories.CATEGORYNAMEHERE %}
    {{ post.content }}
{% endfor %}