Last active
April 2, 2022 20:48
-
-
Save profstein/ede349546adf78740b040e8394dceb33 to your computer and use it in GitHub Desktop.
List of Pages in a Collection (Eleventy)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
{% for page in collections.post %} | |
<li> | |
<a href="{{ page.url }}"> {{ page.data.title }}</a> | |
</li> | |
{% endfor %} | |
</ul> |
You don't have to use 'page' You can call the page whatever you like as long as it is a valid variable name for the template langugage (Nunjucks is used here). This would also work:
<ul>
{% for banana in collections.post %}
<li>
<a href="{{ banana.url }}"> {{ banana.data.title }}</a>
</li>
{% endfor %}
</ul>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will show all pages that have a tag of post in their front matter. To use a different tag you can change what collection is used. For example:
{% for page in collections.blog %}