Skip to content

Instantly share code, notes, and snippets.

@tannerdolby
Last active August 12, 2025 15:53
Show Gist options
  • Save tannerdolby/0fd575a480d0299e1d6735f462799d77 to your computer and use it in GitHub Desktop.
Save tannerdolby/0fd575a480d0299e1d6735f462799d77 to your computer and use it in GitHub Desktop.
11ty filter for returning a sorted list of tags from collections. Use the it in a template like {{ collections.foo | taglist }} to get the sorted tag list.
eleventyConfig.addFilter("taglist", function(collection) {
const tags = [];
collection.forEach(post => {
tags.push(...post.data.tags);
});
const sorted = [...new Set(tags)].sort((a, b) => a.localeCompare(b));
return sorted;
});
@spiralsteno
Copy link

Was looking for a way to just generate a simple alphabetized list of my tags to use as a reference to keep track of my own posting mess, and this works perfectly for that and was extremely well explained. Thank you so much!

@tannerdolby
Copy link
Author

@spiralsteno Awesome, I'm happy to hear it was helpful. No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment