Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display a specific post in Jekyll?

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

like image 788
Sara Weinand Avatar asked Nov 02 '25 08:11

Sara Weinand


1 Answers

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

And on the post;

slug: post_slug

like image 61
bazzlebrush Avatar answered Nov 04 '25 01:11

bazzlebrush