1

Hi I'm working on a Jekyll site. I am using a capture cycle for odd and even displays of the collection. I would also like to specifically target which collections are shown on this page.

Here's the code so far:

{% assign sorted = (site.catalog | sort: 'date') | reverse %}
{% for project in sorted limit: 5 reversed %}

{% capture thecycle %}{% cycle 'odd', 'even' %}{% endcapture %}
    {% if thecycle == 'odd' %}
        {% if project.featured == "1" || project.featured == "3" || project.featured == "5" %}
<div>{{ project.title }} {{ project.subtitle }}</div>
{% endif %}

{% if thecycle == 'even' %}
<div>{{ project.title }} {{ project.subtitle }}</div>
{% endif %}
{% endfor %}

So I would like five items to be shown on this page in total. For the odd cycles, I would like those items to be (1,3,5) to display a certain format, and for the even cycles, I would like those items (2,4) to display a certain format.

The approach I started using would show this variable in the front matter of the collection item:

featured: "1"

Thanks in advance for any help

  • Does this help? http://stackoverflow.com/questions/8980192 – approxiblue Feb 15 '17 at 03:06
  • @approxiblue it does help somewhat, I have more information, now I'm figuring out how to specifically place each collection item within the capture for odd and even. Havent quite figured out the answer yet. – Montier Kess Feb 15 '17 at 19:49
  • 1
    Here's what ended up working for me: `{% assign features = site.catalog | where:"featured", "yes" | sort:"featured-rank" %} {% for project in features limit: 5 %}` -- then basically just add "featured" as a variable in the front matter of each collection, and then sorting takes care of the rest. – Montier Kess Mar 27 '17 at 14:18
  • Nice. You should [post your own answer and accept it](http://stackoverflow.com/help/self-answer). – approxiblue Mar 27 '17 at 15:47

0 Answers0