UsingCircularTemplateContentReferenceError #1850
-
|
Hi, there. My repo is here /d/frontend-template (snowpack)
$ set DEBUG=Eleventy* & npx @11ty/eleventy --dryrun
[1] 1689
Problem writing Eleventy templates: (more in DEBUG output)
> ./src/index.njk contains a circular reference (using collections) to its own templateContent.
`UsingCircularTemplateContentReferenceError` was thrown:
UsingCircularTemplateContentReferenceError: ./src/index.njk contains a circular reference (using collections) to
its own templateContent.
at TemplateMap.populateContentDataInMap (D:\frontend-template\node_modules\@11ty\eleventy\src\TemplateMap.js:384:17)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async TemplateMap.cache (D:\frontend-template\node_modules\@11ty\eleventy\src\TemplateMap.js:303:5)
at async TemplateWriter._createTemplateMap (D:\frontend-template\node_modules\@11ty\eleventy\src\TemplateWriter.js:170:5)
at async TemplateWriter.writeTemplates (D:\frontend-template\node_modules\@11ty\eleventy\src\TemplateWriter.js:203:5)
at async TemplateWriter.write (D:\frontend-template\node_modules\@11ty\eleventy\src\TemplateWriter.js:254:25) at async Eleventy.write (D:\frontend-template\node_modules\@11ty\eleventy\src\Eleventy.js:743:13)
Wrote 0 files in 0.35 seconds (v0.12.1)
[1]+ Done set DEBUG=Eleventy* |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
So, in this line, |
Beta Was this translation helpful? Give feedback.
So, in this line,
excerpttag will extracttemplateContentfrompost. The problem is that thiscollections.allincludes all content including./src/index.njkitself, hence a circular reference error is thrown because it can't get the template content of itself while it's currently rendering.Therefore don't use
collections.all, you can use custom filtering instead withgetFilteredByGlob("./src/posts/*.md")if you only want to include posts.