11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addExtension breaks dynamic permalinks

ironnysh opened this issue · comments

Describe the bug
Hi,
This bug report is a follow-up to #1365 that was partially solved in #6 for eleventy-plugin-vue, but seems to still be an issue.

I'm using @Holben888's awesome snippet from the Eleventy Meetup to run 11ty Image Plugin without a shortcode using addExtension.

Everything works perfectly, except the Dynamic Permalink. Once I add their script to .eleventy.js, I start getting error messages.

To Reproduce

  1. Using either a dynamic permalink in a directory data file or directly in a markdown file

blog/post.md

---
permalink: /blog/{{ page.fileSlug }}/index.html
---

Some text

Or

blog/blog.json

"permalink": "/blog/{{ page.fileSlug }}/index.html"

outputs the following error:

`TemplateContentRenderError` was thrown
[11ty] > Cannot use 'in' operator to search for 'page' in /blog/{{ page.fileSlug }}/index.html, 
line:1, col:1, file:./src/blog/post.md, line:1, col:7
  1. After adding markdownTemplateEngine: "njk" to .eleventy.js, I get this output with the first option (directory data file):
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] > Output conflict: multiple input files are writing to `www/<html><head></head><body>/blog/index.html</body></html>`. Use distinct `permalink` values to resolve this conflict.
  1. ./src/blog/post-two.md
  2. ./src/blog/post.md

`DuplicatePermalinkOutputError` was thrown:
[11ty]     (Repeated output has been truncated…)
        at TemplateMap.checkForDuplicatePermalinks (/Users/liron/Public/11ty-image-optimization-demo/node_modules/@11ty/eleventy/src/TemplateMap.js:651:13)
  1. And this is what happens when using a permalink in the markdown file's front matter (see line 1):
[11ty] Writing www/<html><head></head><body>/blog/index.html</body></html> from ./src/blog/post.md (njk)
[11ty] Writing www/index.html from ./src/index.njk
[11ty] Wrote 2 files in 0.33 seconds (v1.0.0-canary.41)
[11ty] Watching…

Environment:

  • MacOS Big Sur version 11.5.2
  • Eleventy 1.0.0-beta.4

Would appreciate any help :-)

Hey not sure if you saw the comments posted at #1365 to resolve that issue for 1.0 stable.

I also think that this use-case better fits the Transforms feature rather than addExtension, as Transforms will allow you to use it across all input template languages: https://www.11ty.dev/docs/config/#transforms

This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.

If the response works to solve your problem—great! But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and we will reopen the issue. Thanks!

Hi @zachleat,
Yeah, that’s the route I ended up taking (I have hundreds of photos to process, and hoped this would speed things up). Thanks for letting me know!