Getting fancy! How To Create and use Eleventy Collections. The power of Eleventy.
- I had an old old web page that was repetitive. A golf event that AHS Alumni had every year from 2003 until 2008 A great time to learn collections.
- I did !! Its straightforward with a bit of Eleventy magic.
- I kept the "golf" folder
- In that "golf" folder created "golf.json" with
"tags": "golf",
"permalink": false,
- Eleventy collections are added to the collections object by tags in the file front matter. Collections are available to all templates.
- "tags": "golf", creates a "golf" Eleventy collection
- "permalink": false, tells Eleventy not to render or output any files in the "golf" folder unless the front matter permalink for that file is set to something besides false.
- We want to use files in the golf folder as DATA files so therefore do not need to ouput or render any of those files.
- Now create data files in the golf directory. Create as many as you need Example: 2007.html and 2008.html they will not be rendered because we set the permalink to false in golf.json
- Now create 2003.html thru 2008.html and whatever other DATA you might need to fill the collections.
- Pull all the data together via collections in one file or multiple files that are rendered into the final output build file.