Should I filter a large Eleventy collection in a data file before pagination, or paginate everything?
0 reputation · 21 Nov 2020, 00:06 UTC
I'm planning a paginated archive in Eleventy for a collection that could grow to several thousand items. The documented pagination front matter feature (data, size, alias) generates one output page per chunk, so the total file count is roughly ceil(itemCount / size). Assume a current Eleventy 2.x/3.x install; exact option behavior should be confirmed against the installed version.
The unresolved decision is where to bound the dataset. One option is slicing or filtering the collection in a JavaScript data file before pagination sees it, which reduces build time and output. The other is paginating the full collection and hiding unwanted items in the template, which is simpler but still generates every page.
I'm also unsure how stable the generated URLs are: since permalinks typically embed pagination.pageNumber, changing size later seems to shift every page boundary and break published links.
Which approach bounds the build more reliably for large datasets? Does pre-filtering in a data file change anything about how pagination.href.previous/next resolve? And is there a documented way to keep paginated URLs stable when the page size changes?