Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow eleventyExcludeFromCollections to take an array of collections #1175

Closed
paulrobertlloyd opened this issue May 12, 2020 · 8 comments
Closed
Labels
enhancement feature: 📞 collections Related to Eleventy’s tags/collections feature

Comments

@paulrobertlloyd
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I have an index file alongside a group of posts

posts
├─ 01-01-2020-first-post.md
├─ 02-02-2020-second-post.md
├─ index.njk
└─ posts.11tydata.js

posts.11tydata.js adds a post tag to all posts in this folder, and index.njk loops through collection.post, but this loop includes index.njk as well as all the individual posts.

I can exclude the index by using eleventyExcludeFromCollections: true, but that excludes it from all collections. But in my sitemap.xml I want to include it when I use collection.all.

Describe the solution you'd like
Allow eleventyExcludeFromCollections to take an array of collections to be excluded from:

eleventyExcludeFromCollections:
- post
- foo
- bar

Describe alternatives you've considered

Currently I add tags: false to the index file, but it’s not as explicit.

@zachleat zachleat added the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label May 16, 2020
@zachleat
Copy link
Member

I like this idea! It must go into the queue!

This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open.

View the enhancement backlog here. Don’t forget to upvote the top comment with 👍!

@davidhund
Copy link

Apologies if commenting here (and now) is inappropriate.
I'm not entirely sure how the "closed-but-queued issues" thing works. ;-)

Anyway: this gets a strong 👍 from me: Paul's use-case is something I also run into all the time…

@Ryuno-Ki
Copy link
Contributor

@davidhund Basically, Zach's looking at https://github.com/11ty/eleventy#major-roadmapped-features for making decisions.

@architchandra
Copy link

Please add the ability to exclude from collections on a per-collection basis (or include in collections.all while excluding from others). It will be really helpful.

Snapstromegon added a commit to Snapstromegon/eleventy that referenced this issue Jul 1, 2022
…a list of tags

This is a first implementation for 11ty#1175 and 11ty#2287 to gather feedback.

This change allows for more fine grained control over how a template is excluded from collections by allowing to set eleventyExcludeFromCollections to a tag or list of tags to exclude the template from.

This is meant as a first implementation for feedback. Also I'm not completely sure if excluding the `all` Collection is done correctly.

I only added minimal tests, but probably some more are needed.

Signed-off-by: Raphael Höser <raphael@hoeser.info>
@zachleat zachleat added the feature: 📞 collections Related to Eleventy’s tags/collections feature label Jul 1, 2022
@nitin2953
Copy link

Please reopen this issue 😥,
without this feature my directory structure is messing up 😭.

@paulrobertlloyd
Copy link
Contributor Author

@nitin2953 Just because an issue is closed, doesn’t mean it’s not on the roadmap. Things work in a rather strange way on this project.

zachleat added a commit that referenced this issue Nov 10, 2023
…thub.com:Snapstromegon/eleventy into Snapstromegon-#1175-#2287-excludefromcollections-with-tag-list
@zachleat zachleat added this to the Eleventy 3.0.0 milestone Nov 10, 2023
@zachleat zachleat removed the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label Nov 10, 2023
@zachleat
Copy link
Member

#2482 was merged—this will ship with 3.0.

zachleat added a commit to 11ty/11ty-website that referenced this issue May 30, 2024
@zachleat
Copy link
Member

Docs shipping to https://www.11ty.dev/docs/collections/#how-to-exclude-content-from-collections

zachleat added a commit that referenced this issue Jun 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement feature: 📞 collections Related to Eleventy’s tags/collections feature
Projects
None yet
Development

No branches or pull requests

6 participants