I am trying to create a collection within my jekyll page for book reviews.
These are my changes -
# Jekyll collections
# Documentation - https://jekyllrb.com/docs/collections/
collections_dir: collections
collections:
books:
output: true
permalink: /:collection/:title
And this is my folder structure for collections
├── collections
│ ├── books
│ │ ├── index.html
│ │ └── Harry_Potter.md
│ └── index.html
├── _config.yml
Upon starting the jekyll server with jekyll serve
, I’m able to see the page directly under http://localhost:4000/collections/books/Harry-Potter/
But, the index.html
file under collections/
directory is not able to iterate over the list of books and display the pages.
Specifically,
{% for collection in site.collections %}
<section>
<h1>{{ collection.label }}</h1>
</section>
{% endfor %}
</div>
gives the following output -
books
posts
But when I try to print {{ site.books.size }}
as <h1>{{ site.books.size }}</h1>
I get 0
as output.
And for the same reason,
{% for book in site.books %}
<h1>{{ book.title }}</h1>
{% endfor %}
doesn’t generate any output at all.
Why is {{ site.books.size }}
not able to pull up any posts?