Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

95
Views
eleventy collections api - add collections dynamically

I want to create collections dynamically in 11ty.js and for that i have a block of code like so

eleventyConfig.addCollection("myGithub", (collection) => {
    const result = collection.getAll()[0].data.myGithub
    const tags = collection.getAll()[0].data.myGithub.tags
    tags.forEach(tag => {
      console.log('hello')
      eleventyConfig.addCollection(`tag${tag}`, (collection) => {
        const repos = collection.getAll()[0].data.myGithub.repos
        console.log('hello')
        return repos.filter(repo => {
          return repo.data.tags.includes(tag)

        })
      })
    });

    console.log(Object.keys(collection.getAll()[0].data.collections))

    return result
  })

but this seems to skip the inner eleventyConfig.addCollection as i don't see those console.log statements, and i am wondering if something in 11ty is stopping me from doing this. if not, what am i doing wrong?

not always, but sometimes i also get an error like

UserConfigError: config.addCollection(HTML) already exists. Try a different name for your collection.
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!