i display last 10 posts in jekyll blog assuming show
attribute true
.
e.g. yaml front matter might this
--- title: "so question" categories: question show: false ---
in index.html
file have following
{% post in site.posts limit:10 %} {% if post.show %} <!-- display post --> {% endif %} {% endfor %}
but if 1 post of last 10 has show
attribute of false
, 9 posts appear on page.
jinja2 suppports for-if
syntax seen here: http://jinja.pocoo.org/docs/dev/templates/#for. solve problem, unfortunately not supported liquid.
using liquid how can condition on post attribute , make sure 10 posts displayed?
you have first make array posts have show
variable set true
.
{% assign publishedposts = site.posts | where: 'show', 'true' %}
you can make
{% p in publishedposts limit:10 %}
Comments
Post a Comment