Skip to content

Customizing 11ty Collections

Posted on: Nov 23, 2020 by Stephanie Eckles
🍿 1 min. read

Create randomized and other variations for your Eleventy collections.

#randomizedPosts Collection

Create a randomized version of a tag collection.

As opposed to the random filters, a collection will persist throughout your site, whereas filters used on multiple pages will produce randomized results per page.

eleventyConfig.addCollection("randomizedPosts", function (collection) {
return (
// Change to the name of your tag
.sort(() => {
return 0.5 - Math.random();
// Optional limit, remove if unwanted
.slice(0, 3)

#Collections Based on Frontmatter

Useful for when you may not want to create the collections by duplicating tags and instead use a custom frontmatter key.

eleventyConfig.addCollection("specialCollection", function (collection) {
return collection.getAll().filter((post) =>;
View more config samples