Now to tackle Liquid to create that index listing.
Step 1: Iterate your collection pages with a for loop
- Edit your _connecttech2018/index.md file
- Add a for loop to create a link for each item in the collection.
<ol>
{% for item in site.connecttech2018 %}
<li><a href="{{item.url}}">{{item.title}}</a></li>
{% endfor %}
</ol>
Save and Commit.
Dang!
Anybody see the problem?
Yes, the collection iterates *all* files as items, including the index. There are a few ways to solve this problem. Today I'm going to use it as an opportunity to teach a few more Liquid tricks.
Step 3: Use more Liquid to exclude the index page from iteration
1. Assign the collection to a liquid variable
{% assign sessions = site.connecttech2018 %}
<ol>
{% for item in sessions %}
<li><a href="{{item.url}}">{{item.title}}</a></li>
{% endfor %}
</ol>
2. Apply a where_exp filter for a specific variable
where and where_exp are jekyll specific liquid filters to match elements based on front matter variables.
{% assign sessions = site.connecttech2018 | where_exp: "item", "item.exclude != true "%}
Warning I always seem to get this syntax wrong at first… If it didn’t work check your server output for help.
3. Add exclude: true to your index.md front matter
Extra Credit
- What’s truthy for the where_exp?
- Start your own Liquid cheatsheet from examples in the docs.