Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Collections/pagination oddity in 1.0.0 #2161

Closed
brycewray opened this issue Jan 9, 2022 · 15 comments
Closed

Collections/pagination oddity in 1.0.0 #2161

brycewray opened this issue Jan 9, 2022 · 15 comments
Labels

Comments

@brycewray
Copy link

brycewray commented Jan 9, 2022

The bug:
Beginning in 1.0.0, templating which formerly allowed for paginated output of a collection is broken. (Error message output below.) I didn't see this bug when using any of the 1.x beta versions, nor with any other Eleventy version all the way back to 0.9.0 in 2019.

To reproduce:
Steps to reproduce the behavior:

  1. Upgrade the site to Eleventy 1.0.0.
  2. Run Eleventy (npx @11ty/eleventy in package.json).
  3. The build attempt fails with an error message (below).

Expected behavior:
The site would build, with normal "posts" collections pagination (151 posts, paginated 5-per-page) on the /posts route, as it always did prior to version 1.0.0.

Error message:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] > Output conflict: multiple input files are writing to `_site/posts/index.html`. Use distinct `permalink` values to resolve this conflict.
  1. ./src/posts/posts.njk
  2. ./src/posts/posts.njk
  3. ./src/posts/posts.njk
  4. ./src/posts/posts.njk
  5. ./src/posts/posts.njk
  6. ./src/posts/posts.njk
  7. ./src/posts/posts.njk
  8. ./src/posts/posts.njk
  9. ./src/posts/posts.njk
  10. ./src/posts/posts.njk
  11. ./src/posts/posts.njk
  12. ./src/posts/posts.njk
  13. ./src/posts/posts.njk
  14. ./src/posts/posts.njk
  15. ./src/posts/posts.njk
  16. ./src/posts/posts.njk
  17. ./src/posts/posts.njk
  18. ./src/posts/posts.njk
  19. ./src/posts/posts.njk
  20. ./src/posts/posts.njk
  21. ./src/posts/posts.njk
  22. ./src/posts/posts.njk
  23. ./src/posts/posts.njk
  24. ./src/posts/posts.njk
  25. ./src/posts/posts.njk
  26. ./src/posts/posts.njk
  27. ./src/posts/posts.njk
  28. ./src/posts/posts.njk
  29. ./src/posts/posts.njk
  30. ./src/posts/posts.njk
  31. ./src/posts/posts.njk

`DuplicatePermalinkOutputError` was thrown:
[11ty]     (Repeated output has been truncated…)
        at TemplateMap.checkForDuplicatePermalinks (/Users/thewrays/eleventy_site/node_modules/@11ty/eleventy/src/TemplateMap.js:656:13)
        at TemplateMap.cache (/Users/thewrays/eleventy_site/node_modules/@11ty/eleventy/src/TemplateMap.js:365:10)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
        at async TemplateWriter._createTemplateMap (/Users/thewrays/eleventy_site/node_modules/@11ty/eleventy/src/TemplateWriter.js:242:5)
        at async TemplateWriter.generateTemplates (/Users/thewrays/eleventy_site/node_modules/@11ty/eleventy/src/TemplateWriter.js:275:5)
        at async TemplateWriter.write (/Users/thewrays/eleventy_site/node_modules/@11ty/eleventy/src/TemplateWriter.js:321:23)
        at async Eleventy.executeBuild (/Users/thewrays/eleventy_site/node_modules/@11ty/eleventy/src/Eleventy.js:986:13)
        at async Eleventy.watch (/Users/thewrays/eleventy_site/node_modules/@11ty/eleventy/src/Eleventy.js:829:18)
[11ty] Copied 67 files / Wrote 0 files in 1.94 seconds (v1.0.0)
ERROR: "dev:eleventy" exited with 1.

Environment:

  • OS and version: macOS 12.1
  • Eleventy Version 1.0.0

Additional context:
My repo where I'm seeing this behavior: https://github.com/brycewray/eleventy_site
See also this Discord thread.

@zachleat zachleat added this to the Eleventy 1.0.1 milestone Jan 9, 2022
@pdehaan
Copy link
Contributor

pdehaan commented Jan 9, 2022

Possible workaround: Explicitly set the permalink value for the pagination:

diff --git a/src/posts/posts.njk b/src/posts/posts.njk
index a3832d1d..a9e48420 100644
--- a/src/posts/posts.njk
+++ b/src/posts/posts.njk
@@ -11,6 +11,7 @@ pagination:
   size: 5
   reverse: true
   alias: posts
+permalink: "posts/{% if pagination.pageNumber != 0 %}page-{{ pagination.pageNumber + 1 }}/{% endif %}"
 ---
   <main>
     <div class="text-center px-10 w-full lg:w-4/5 mx-auto">

OUTPUT

[11ty] Copied 67 files / Wrote 191 files in 4.69 seconds (24.6ms each, v1.0.0)
 tree _site/posts

_site/posts
├── 2018
│   ├── 09
│   │   ├── ...
├── index.html
├── page-10
│   └── index.html
├── page-11
│   └── index.html
├── ...
└── page-9
    └── index.html

227 directories, 182 files

@brycewray
Copy link
Author

@pdehaan Thanks! Actually, project is good for now, so I can wait until this is resolved. Since it was fine prior to 1.0 (and others are having the issue), am assuming a fix will come.

@zachleat
Copy link
Member

zachleat commented Jan 9, 2022

First thought was that it might be related to #1956 Did you test beta 10 or canary 50?

@brycewray
Copy link
Author

First thought was that it might be related to #1956 Did you test beta 10 or canary 50?

No. I upgraded to 1.0.0 from 1.0.0-beta.2; and I never used any canary version.

@zachleat
Copy link
Member

zachleat commented Jan 9, 2022

Can you test Beta 9 and see if it works? (and optionally Beta 10 to see if it doesn’t)

@brycewray
Copy link
Author

Tried installing each without success (got the No matching version found for error), even though I matched the version names shown on the Tags page:

npm i -D @11ty/[email protected]

npm i -D @11ty/[email protected]

Is my syntax wrong?

@pdehaan
Copy link
Contributor

pdehaan commented Jan 9, 2022

Weird, I can do npm i @11ty/[email protected] (macOS Monterey 12.1).

Beta.9; Copied 67 files / Wrote 191 files in 3.98 seconds (20.8ms each, v1.0.0-beta.9)

npm i @11ty/[email protected]
# ...
npm run build

> eleventy_site@ build /private/tmp/eleventy_site
> NODE_ENV=production npm-run-all clean hasher --parallel prod:*


> eleventy_site@ clean /private/tmp/eleventy_site
> rimraf _site


> eleventy_site@ hasher /private/tmp/eleventy_site
> node csshash.js && node jshash.js

CSS MD5 result = c2c5ee1e17ed2d829e6f6c49f254b611
SCSS MD5 result = 30f8755e509dc9d7d298effaea5aa9cb
lazyload MD5 result =  1d2c58e751fd3b47be66ebbfa961cc0f

> eleventy_site@ prod:eleventy /private/tmp/eleventy_site
> ELEVENTY_ENV=production npx @11ty/eleventy --output=./_site


> eleventy_site@ prod:twcss /private/tmp/eleventy_site
> tailwindcss --postcss -i src/assets/css/index.css -o _site/css/$(cat csshash-out) --minify

...
[@11ty/eleventy-upgrade-help] PASSED `slug` to `slugify` filter
[@11ty/eleventy-upgrade-help] WARNING eleventyConfig.setDataDeepMerge(true) is the new 1.0 default. Revert with eleventyConfig.setDataDeepMerge(false);
[@11ty/eleventy-upgrade-help] WARNING The liquidjs `strictFilters` option default (in Eleventy) changed from false to true. Revert with `eleventyConfig.setLiquidOptions({ strictFilters: false })`.
[@11ty/eleventy-upgrade-help] WARNING The liquidjs `dynamicPartials` option default changed from false to true. Functionally this means `include` statements require quotes now. Revert with `eleventyConfig.setLiquidOptions({ dynamicPartials: false })`.
[@11ty/eleventy-upgrade-help] PASSED input directory .gitignore check
[11ty] Copied 67 files / Wrote 191 files in 3.98 seconds (20.8ms each, v1.0.0-beta.9)

Beta.10; Copied 67 files / Wrote 0 files in 2.84 seconds (v1.0.0-beta.10)

npm i @11ty/[email protected]
# ...
npm run build

> eleventy_site@ build /private/tmp/eleventy_site
> NODE_ENV=production npm-run-all clean hasher --parallel prod:*


> eleventy_site@ clean /private/tmp/eleventy_site
> rimraf _site


> eleventy_site@ hasher /private/tmp/eleventy_site
> node csshash.js && node jshash.js

CSS MD5 result = c2c5ee1e17ed2d829e6f6c49f254b611
SCSS MD5 result = 30f8755e509dc9d7d298effaea5aa9cb
lazyload MD5 result =  1d2c58e751fd3b47be66ebbfa961cc0f

> eleventy_site@ prod:eleventy /private/tmp/eleventy_site
> ELEVENTY_ENV=production npx @11ty/eleventy --output=./_site


> eleventy_site@ prod:twcss /private/tmp/eleventy_site
> tailwindcss --postcss -i src/assets/css/index.css -o _site/css/$(cat csshash-out) --minify

...
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] > Output conflict: multiple input files are writing to `./_site/posts/index.html`. Use distinct `permalink` values to resolve this conflict.
  1. ./src/posts/posts.njk
  2. ./src/posts/posts.njk
  3. ./src/posts/posts.njk
  4. ./src/posts/posts.njk
  5. ./src/posts/posts.njk
  6. ./src/posts/posts.njk
  7. ./src/posts/posts.njk
  8. ./src/posts/posts.njk
  9. ./src/posts/posts.njk
  10. ./src/posts/posts.njk
  11. ./src/posts/posts.njk
  12. ./src/posts/posts.njk
  13. ./src/posts/posts.njk
  14. ./src/posts/posts.njk
  15. ./src/posts/posts.njk
  16. ./src/posts/posts.njk
  17. ./src/posts/posts.njk
  18. ./src/posts/posts.njk
  19. ./src/posts/posts.njk
  20. ./src/posts/posts.njk
  21. ./src/posts/posts.njk
  22. ./src/posts/posts.njk
  23. ./src/posts/posts.njk
  24. ./src/posts/posts.njk
  25. ./src/posts/posts.njk
  26. ./src/posts/posts.njk
  27. ./src/posts/posts.njk
  28. ./src/posts/posts.njk
  29. ./src/posts/posts.njk
  30. ./src/posts/posts.njk
  31. ./src/posts/posts.njk

`DuplicatePermalinkOutputError` was thrown:
[11ty]     (Repeated output has been truncated…)
        at TemplateMap.checkForDuplicatePermalinks (/private/tmp/eleventy_site/node_modules/@11ty/eleventy/src/TemplateMap.js:656:13)
        at TemplateMap.cache (/private/tmp/eleventy_site/node_modules/@11ty/eleventy/src/TemplateMap.js:365:10)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async TemplateWriter._createTemplateMap (/private/tmp/eleventy_site/node_modules/@11ty/eleventy/src/TemplateWriter.js:242:5)
        at async TemplateWriter.generateTemplates (/private/tmp/eleventy_site/node_modules/@11ty/eleventy/src/TemplateWriter.js:275:5)
        at async TemplateWriter.write (/private/tmp/eleventy_site/node_modules/@11ty/eleventy/src/TemplateWriter.js:321:23)
        at async Eleventy.executeBuild (/private/tmp/eleventy_site/node_modules/@11ty/eleventy/src/Eleventy.js:986:13)
[11ty] Copied 67 files / Wrote 0 files in 2.84 seconds (v1.0.0-beta.10)

@brycewray
Copy link
Author

brycewray commented Jan 9, 2022

@pdehaan Thanks. Tried it without -D as well (as per yours) and still no joy. Anyway, looks like you showed @zachleat what he needed to see.

Also, FWIW, I did npm view @11ty/eleventy and saw that beta is 1.0.0-beta.10, so tried npm i -D @11ty/eleventy@beta and, sure enough, it loaded that version (of course, still has the same bug, as in what @pdehaan showed above). No idea why the other requests for specific versions didn't work. 🤷‍♂️

@pdehaan
Copy link
Contributor

pdehaan commented Jan 10, 2022

@brycewray Fascinating. I wonder why you cant find the older versions in the npm registry.

npm info @11ty/eleventy dist-tags versions --json

{
  "dist-tags": {
    "latest": "1.0.0",
    "beta": "1.0.0-beta.10",
    "canary": "1.0.0-canary.50"
  },
  "versions": [
    "0.2.0",
    "0.2.1",
    "0.2.2",
    "0.2.3",
    "0.2.4",
    "0.2.5",
    "0.2.6",
    "0.2.7",
    "0.2.8",
    "0.2.9",
    "0.2.10",
    "0.2.11",
    "0.2.12",
    "0.2.13",
    "0.2.14",
    "0.2.15",
    "0.3.0",
    "0.3.1",
    "0.3.2",
    "0.3.3",
    "0.3.4",
    "0.3.5",
    "0.3.6",
    "0.4.0",
    "0.5.0",
    "0.5.1",
    "0.5.2",
    "0.5.3",
    "0.5.4",
    "0.6.0",
    "0.7.0",
    "0.7.1",
    "0.8.0-beta.1",
    "0.8.0",
    "0.8.1",
    "0.8.2",
    "0.8.3",
    "0.9.0-beta.1",
    "0.9.0-beta.2",
    "0.9.0-beta.3",
    "0.9.0",
    "0.10.0-beta.1",
    "0.10.0-beta.2",
    "0.10.0",
    "0.11.0-beta.1",
    "0.11.0-beta.2",
    "0.11.0-beta.3",
    "0.11.0-beta.4",
    "0.11.0",
    "0.11.1",
    "0.12.0",
    "0.12.1",
    "1.0.0-beta.1",
    "1.0.0-beta.2",
    "1.0.0-beta.3",
    "1.0.0-beta.4",
    "1.0.0-beta.5",
    "1.0.0-beta.6",
    "1.0.0-beta.7",
    "1.0.0-beta.8",
    "1.0.0-beta.9",
    "1.0.0-beta.10",
    "1.0.0-canary.1",
    "1.0.0-canary.2",
    "1.0.0-canary.3",
    "1.0.0-canary.4",
    "1.0.0-canary.5",
    "1.0.0-canary.6",
    "1.0.0-canary.7",
    "1.0.0-canary.8",
    "1.0.0-canary.9",
    "1.0.0-canary.10",
    "1.0.0-canary.11",
    "1.0.0-canary.12",
    "1.0.0-canary.13",
    "1.0.0-canary.14",
    "1.0.0-canary.15",
    "1.0.0-canary.16",
    "1.0.0-canary.17",
    "1.0.0-canary.18",
    "1.0.0-canary.19",
    "1.0.0-canary.20",
    "1.0.0-canary.21",
    "1.0.0-canary.22",
    "1.0.0-canary.23",
    "1.0.0-canary.24",
    "1.0.0-canary.25",
    "1.0.0-canary.26",
    "1.0.0-canary.27",
    "1.0.0-canary.28",
    "1.0.0-canary.29",
    "1.0.0-canary.30",
    "1.0.0-canary.31",
    "1.0.0-canary.32",
    "1.0.0-canary.33",
    "1.0.0-canary.34",
    "1.0.0-canary.35",
    "1.0.0-canary.36",
    "1.0.0-canary.37",
    "1.0.0-canary.38",
    "1.0.0-canary.39",
    "1.0.0-canary.40",
    "1.0.0-canary.41",
    "1.0.0-canary.42",
    "1.0.0-canary.43",
    "1.0.0-canary.44",
    "1.0.0-canary.45",
    "1.0.0-canary.46",
    "1.0.0-canary.47",
    "1.0.0-canary.48",
    "1.0.0-canary.49",
    "1.0.0-canary.50",
    "1.0.0"
  ]
}

And looks like I'm using the official npm registry at https://registry.npmjs.org/:

npm config ls -l | grep registry

metrics-registry = "https://registry.npmjs.org/"
; metrics-registry = null (overridden)
registry = "https://registry.npmjs.org/"

The output is too large to dump here, but you can get all the npm info (dist-tags, versions, times, .tgz info, etc) for @11ty/eleventy using npm info @11ty/eleventy --json.

@brycewray
Copy link
Author

@pdehaan Yes, it's as if my npm i is pulling from a different place where not all the versions exist. Very weird stuff.

@brycewray
Copy link
Author

brycewray commented Jan 10, 2022

@pdehaan Just FYI: this morning, out of curiosity, tried the following and was able to load both beta.9 and beta.10 successfully thereafter:

  1. Turned on the Cloudflare 1.1.1.1 tool on the Mac, which automatically disabled the macOS Private Relay feature (and I did try turning that off yesterday but had no luck with the loads).
  2. Did both loads.
  3. Turned Cloudflare 1.1.1.1 back off and re-enabled Private Relay.
  4. Repeated the loads successfully, settling on beta.9.

Once again — 🤷‍♂️. Have now reverted my repo to beta.9 for now and it works just fine, as your fork did. Guess I'll stick with that version until there's a resolution to this issue in stable 1.0.x.

Thanks again!

@zachleat
Copy link
Member

I don’t think this is the same issue as #2167 BUT I do this the fix that went up for #2167 will likely fix this one too. Please retest after 2.0.0-canary.5 is shipped!

@zachleat zachleat added bug waiting-to-close Issue that is probably resolved, waiting on OP confirmation. and removed needs-triage labels Apr 15, 2022
@5t3ph
Copy link

5t3ph commented Jun 4, 2022

Hey @zachleat - here to report I think a related issue as of v2.0.0-canary.11. Here's my test repo: https://github.com/5t3ph/issue-11ty-collection-pagination

(Happy to move to a new issue if you think it's separate)

Does it seem to be a data cascade issue for the permalinks, perhaps?

Error output
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] Output conflict: multiple input files are writing to `public/pagination/page-one/index.html`. Use distinct `permalink` values to resolve this conflict.
[11ty]   1. ./src/pages/page-one.11ty.js
[11ty]   2. ./src/_pagination.njk (via DuplicatePermalinkOutputError)
[11ty] 
[11ty] Original error stack trace: (Repeated output has been truncated…)
[11ty]     at TemplateMap.checkForDuplicatePermalinks (/Users/5t3ph/Repos/issue-11ty-collection-pagination/node_modules/@11ty/eleventy/src/TemplateMap.js:659:13)
[11ty]     at TemplateMap.cache (/Users/5t3ph/Repos/issue-11ty-collection-pagination/node_modules/@11ty/eleventy/src/TemplateMap.js:368:10)
[11ty]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[11ty]     at async TemplateWriter._createTemplateMap (/Users/5t3ph/Repos/issue-11ty-collection-pagination/node_modules/@11ty/eleventy/src/TemplateWriter.js:244:5)
[11ty]     at async TemplateWriter.generateTemplates (/Users/5t3ph/Repos/issue-11ty-collection-pagination/node_modules/@11ty/eleventy/src/TemplateWriter.js:277:5)
[11ty]     at async TemplateWriter.write (/Users/5t3ph/Repos/issue-11ty-collection-pagination/node_modules/@11ty/eleventy/src/TemplateWriter.js:324:23)
[11ty]     at async Eleventy.executeBuild (/Users/5t3ph/Repos/issue-11ty-collection-pagination/node_modules/@11ty/eleventy/src/Eleventy.js:1068:13)
[11ty]     at async Eleventy.watch (/Users/5t3ph/Repos/issue-11ty-collection-pagination/node_modules/@11ty/eleventy/src/Eleventy.js:906:18)
[11ty] Wrote 0 files in 0.07 seconds (v2.0.0-canary.11)

@zachleat
Copy link
Member

@5t3ph sorry for the late reply here—this was indeed a different issue! (EXCELLENT test case tho)

I tracked down the issue to #1173

---
pagination:
  data: collections.pages
  size: 1
  alias: blah
permalink: "/pagination/{{ blah.fileSlug }}/"
---
{{ blah.fileSlug | log }}

works as expected. Please upvote #1173!

@zachleat
Copy link
Member

Closing this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants