I’d like to list a fixed number of recent posts having the same category as the current post. This is what I have arrived at:
{% for category_name in page.categories limit:1 %}
<h2>Other articles in {{ category_name }}</h2>
<ul>
<!-- now what? -->
</ul>
{% endfor %}
I know about site.categories
, but I don’t know how to subscript the dictionary. Obviously, site.categories.category_name
is taken literally, looking for a category named “category_name”.
{% for post in site.categories[category_name] %}
<li>{{ post.title }}</li>
{% 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