Layout Page Not Using Variable

#1

Hello,
I’m trying to list tags for specific categories in Jekyll. For this, I have an index page for each category. All these pages have a different variable called “category” in their front matter. And they all use the same layout page. In the layout page, I’m running this code to filter tags in specific categories.

 {% for post in site.categories['{{page.category}}'] %}
    {% for tag in post.tags %}
     {{ tag  }}
   {% endfor %}
 {% endfor %}

However this doesn’t work. If I change the [’{{page.category}}’] with the name of each category, it does what I need; but that defeats the purpose of using a layout.

I’m a total newbie in web programming and Jekyll, so apologies if this doesn’t make sense. Any help would be greatly appreciated, thanks!

0 Likes

#2

Did you try:

{% for post in site.categories[page.category] %}
0 Likes

#4

I’ve tried a few different formats with the brackets but it looks like I’ve missed that one. It did the trick nicely - thanks a lot!

1 Like