This is probably an easy question, but how do I show previews of my posts on the default page? I am using the Jekyll Bootstrap theme Tom.
This also works at least as of 1.0.0
, is built in and is simple to use.
<ul> {% for post in site.posts %} <li> <a href="{{ post.url }}">{{ post.title }}</a> <p>{{ post.excerpt }}</p> </li> {% endfor %} </ul>
See here.
Looking through the functions here, I found strip_html and truncatewords.
Here's a sample "posts list" with 75 words of preview text.
<ul > {% for post in site.posts limit 4 %} <li><span>{{ post.date | date_to_string }}</span> » <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li> {{ post.content | strip_html | truncatewords:75}}<br> <a href="{{ post.url }}">Read more...</a><br><br> {% endfor %} </ul>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With