What are the advantages of using collections than data files? They seem to be able to achieve the same purpose. Plus usually we have data files of items (e.g. JSON, csv), then I have to transform them if using collections. The differentiation between posts vs collections/datafile is clearer but I am confused when should I use collections vs data files.
TL;DR:
Longer answer:
In practice, collections and data are very similar.
A good way to think of the difference is: collections generally have their own page, data are supplemental information that you want to load dynamically or reuse on more than one page.
So for example, I manage a website that includes many user testimonials that are referenced on specific project pages. Testimonials do not have their own page, and there's no index of testimonials. So I use a data yaml testimonials.yml
file for those.
The site has projects (it's a professional portfolio), and each project has its own page, URL, etc. In this case, I define a collection for my projects.
Jekyll blog posts are basically just a collection that's pre-defined.
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