Eleventy permalink output conflict when more than 2 pages added to collection

148 views Asked by At

I'm having the strangest issue with permalinks and could use some help.

  • Windows 11
  • Eleventy 2.0.1
  • Nunjucks engine

Repo: https://github.com/wcDogg/eleventy-test

  • npm run build - No errors
  • Move test-c.md to either /c_blog/ or /c_docs/
  • npm run build - Output conflict

I discovered this in a larger project and reproduced it in the repo above:

  • There 2 collections defined in .eleventy.js - blog and docs.
  • Each collection has it's own a directory - c_blog and c_docs.
  • Each directory has a JSON with a default permalink like this: "permalink": "/blog/{{ page.fileSlug }}/".
  • Each directory has an index.html where the default is overridden like this: permalink: /blog/.

This works as expected for the index.html, test-a.md, and test-b.md. However, once a test-c.md is added to either collection, I get this:

[11ty] Output conflict: multiple input files are writing to `public/blog/index.html`. Use distinct `permalink` values to resolve this conflict.
[11ty]   1. ./src/c_blog/index.html
[11ty]   2. ./src/c_blog/index.html (via DuplicatePermalinkOutputError)

I'm not sure what's going on or how to investigate further - any help would be much appreciated :)

1

There are 1 answers

0
wcDogg On

Issue happens when using pagination.

In my case, I had size: 2. After the second post, there is a /blog/1/index.html that the permalink doesn't account for. Solution is to use:

permalink: "/blog{% if pagination.pageNumber > 0 %}/{{ pagination.pageNumber }}{% endif %}/index.html"

Many thanks to the Eleventy Discord community for this :)