I have a folder of markdown files each with a number of key/values. I need to filter all of the markdown files in the _faq
folder by the key faq_category
.
I have tried:
{% assign post = site.faqs | where: "faq_category", name-of-category %}
<ul>
<li>{{ post.title }}</li>
</ul>
However, this is showing nothing in the end.
The folder structure it should be looping through is:
jekyll
|
--faqs
|
--name-of-faq
--name-of-faq-2
Sample markdown file:
title: name of faq
faq_id: 2567
slug: title-of-faq
created: Mar 6, 2017
modified: Mar 6, 2017
faq_category: how to fly
Instead of site.faqs
use site.posts
to get an array of posts.
Then put the markdown files in the folder: /faqs/_posts/
for example: /faqs/_posts/faq1.md
.
After that you should be able to browse them like:
{% for post in site.posts %}
{{post.title}}
{% endfor %}
To filter a specific category use: site.categories.CATEGORY
or filter them like: (for example the category "mycategory")
<ul>
{% for post in site.faqs %}
{% if post.categories contains "mycategory" %}
<li>{{ post.title }}</li>
{% endif %}
{% endfor %}
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