Does anyone know why nunjucks conditionals don't work when there's a dash? Code example:

{% for post in collections.story-1 %}
<li><a href="{{ post.url }}">{{ post.data.title }}</a></li>
{% endfor %}

Because when I wrote this instead of looking for markdown files with the "story-1" tag like expected nothing loads. (There's no terminal errors either.)

1st screenshot is how I want it to look, 2nd screenshot is what shows up.

#WebDev #Coding #11ty #Nunjucks

Is the hyphen a shorthand for something like excluding instead? 🤔

I'm asking about this because I don't want to make my tags unreadable just so it can function the way I want it to.

@QueensRambleRoomFFCASH Do underscores work? While I'm not specifically familiar with this particular software, special characters usually don't work in identifiers, except for underscore. It's not as clean as dashes, but still similar.

@QueensRambleRoomFFCASH You may also be able to use the quoted string syntax like {% for post in collections["story-1"] %}

https://mozilla.github.io/nunjucks/templating.html#variables

Nunjucks

@tahosa Someone suggested me this earlier and sadly it didn't work. 😔
@tahosa actually wait i might need to try doing this again just to be sure.
@tahosa ok update: somehow it worked this time. i might've wrote it wrong when i made that post, i should stop coding late at night. 🥴