-
-
Notifications
You must be signed in to change notification settings - Fork 552
Description
Operating system
MacOS Sequoia 15.6.1
Eleventy
3.1.2
Describe the bug
This is a change in behavior from 3.0.0 to 3.1.2.
I have a folder-level data file /blog/blog.11tydata.js
import { constructID } from "../../_config/SchemaOrg.js"
export default {
layout: "layouts/post.njk",
tags: ["post"],
eleventyComputed: {
folder_js: [
{
"@type": "WebPage",
"@id": (data) => { return constructID(data.page.url, data.metadata.url, "#webpage-foo") },
"@id2": "{{ page.url | constructID(metadata.url, '#webpage-bar') }}",
name: "{{ page.url }}",
description: "{{ description }}",
url: "{{ page.url | constructID(metadata.url, '') }}",
},
],
eleventyNavigation: {
key: "{{ title | slugify }}",
parent: "Blog",
title: "{{ title }}"
},
}
};
Which uses a function (also utilized as Nunjucks filter)
import { HtmlBasePlugin } from "@11ty/eleventy";
const constructID = (relative_url, base, fragment) => {
if (fragment === undefined) { console.log(" ...", relative_url, base, fragment) }
console.log("...", relative_url, base, fragment)
try {
console.log("... ..", typeof(relative_url), typeof(base), typeof(fragment))
const u = HtmlBasePlugin.applyBaseToUrl(fragment, base, {
// pathPrefix: eleventyConfig.pathPrefix || "",
pageUrl: relative_url
});
console.log("========", u);
return u;
} catch (e) {
console.log("constructID error: ", e);
throw e;
}
};
export { constructID };
and in filters.js
eleventyConfig.addFilter("constructID", constructID);
Both attributes "@id" and "@id2" are computed fine in 3.0.0
Debug complains in my function about constructID error: Error: pathPrefix (String) is required in the
url filter.
- Indicating that the metadata.url
is undefined. However, this seems to get corrected in the second path of computedData?
However, when I install 3.1.2, the "@id" field goes missing, and the "@id2" field always contains the URL for .../blog/post1/
on the URLs /blog/
, /blog/post1/
, and /blog/post2/
These are silent errors now, as debug does not complain anymore.
Here is the debug output under 3.0.0
2025-08-27T14:57:45.121Z Eleventy:Template First round of computed data for './content/blog/post1.md'
2025-08-27T14:57:45.122Z Eleventy:ComputedData 'page.url' accesses [] variables
2025-08-27T14:57:45.122Z Eleventy:ComputedData 'page.outputPath' accesses [] variables
2025-08-27T14:57:45.123Z Eleventy:ComputedData 'folder_js.0.@type' accesses [] variables
... https://example.com/ #webpage-foo
... .. string string string
======== https://example.com/#webpage-foo
2025-08-27T14:57:45.123Z Eleventy:ComputedData 'folder_js.0.@id' accesses [ 'page.url', 'metadata.url' ] variables
... (((11ty(((page.url)))11ty))) undefined #webpage-bar
... .. string undefined string
constructID error: Error: pathPrefix (String) is required in the `url` filter.
at default (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Filters/Url.js:17:9)
at Function.transformUrl [as applyBaseToUrl] (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Plugins/HtmlBasePlugin.js:44:9)
at Context.constructID (file:///Users/entitygarden/git/eleventy_computed_3_1_2/_config/schemaOrg.js:8:29)
at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/UserConfig.js:419:24)
at Context.fn (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Benchmark/BenchmarkGroup.js:37:23)
at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:109:15)
at Template.root [as rootRenderFunc] (eval at _compile (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:9:62)
at Template.render (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:454:10)
at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:435:10
at new Promise (<anonymous>)
2025-08-27T14:57:45.125Z Eleventy:TemplateContent Having trouble rendering md template ./content/blog/post1.md: "{{ page.url | constructID(metadata.url, '#webpage-bar') }}"
2025-08-27T14:57:45.125Z Eleventy:ComputedDataTemplateString Computed Data first pass data resolution error: TemplateContentRenderError: Having trouble rendering md template ./content/blog/post1.md at Template._render (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateContent.js:624:6) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async ComputedDataTemplateString.findVarsUsed (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedDataTemplateString.js:57:13) at async ComputedData.resolveVarOrder (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedData.js:74:17) at async ComputedData.setupData (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedData.js:104:3) at async Template.addComputedData (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Template.js:563:4) at async Template.getTemplates (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Template.js:733:4) at async TemplateMap.initDependencyMap (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateMap.js:376:18) at async TemplateMap.cache (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateMap.js:425:3) at async TemplateWriter._createTemplateMap (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateWriter.js:356:3) { originalError: Template render error: (./content/blog/post1.md) EleventyNunjucksError: Error in Nunjucks Filter `constructID` (undefined) at Object.handleError (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/runtime.js:227:12) at Template.root [as rootRenderFunc] (eval at _compile (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:17:14) at Template.render (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:454:10) ... 6 lines matching cause stack trace ... at async ComputedDataTemplateString.findVarsUsed (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedDataTemplateString.js:57:13) { lineno: 0, colno: 0, firstUpdate: false, Update: [Function: Update], [cause]: EleventyNunjucksError: Error in Nunjucks Filter `constructID` (undefined) at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:111:11) at Template.root [as rootRenderFunc] (eval at _compile (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:9:62) at Template.render (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:454:10) at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:435:10 at new Promise (<anonymous>) at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:434:11 at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Markdown.js:69:13 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async Template._render (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateContent.js:608:19) at async ComputedDataTemplateString.findVarsUsed (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedDataTemplateString.js:57:13) { originalError: Error: pathPrefix (String) is required in the `url` filter. at default (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Filters/Url.js:17:9) at Function.transformUrl [as applyBaseToUrl] (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Plugins/HtmlBasePlugin.js:44:9) at Context.constructID (file:///Users/entitygarden/git/eleventy_computed_3_1_2/_config/schemaOrg.js:8:29) at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/UserConfig.js:419:24) at Context.fn (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Benchmark/BenchmarkGroup.js:37:23) at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:109:15) at Template.root [as rootRenderFunc] (eval at _compile (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:9:62) at Template.render (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:454:10) at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:435:10 at new Promise (<anonymous>) } } }
2025-08-27T14:57:45.125Z Eleventy:ComputedData 'folder_js.0.@id2' accesses [] variables
2025-08-27T14:57:45.126Z Eleventy:ComputedData 'folder_js.0.name' accesses [ 'page.url' ] variables
2025-08-27T14:57:45.126Z Eleventy:ComputedData 'folder_js.0.description' accesses [] variables
... (((11ty(((page.url)))11ty))) undefined
... .. string undefined string
constructID error: Error: pathPrefix (String) is required in the `url` filter.
at default (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Filters/Url.js:17:9)
at Function.transformUrl [as applyBaseToUrl] (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Plugins/HtmlBasePlugin.js:44:9)
at Context.constructID (file:///Users/entitygarden/git/eleventy_computed_3_1_2/_config/schemaOrg.js:8:29)
at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/UserConfig.js:419:24)
at Context.fn (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Benchmark/BenchmarkGroup.js:37:23)
at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:109:15)
at Template.root [as rootRenderFunc] (eval at _compile (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:9:62)
at Template.render (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:454:10)
at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:435:10
at new Promise (<anonymous>)
2025-08-27T14:57:45.126Z Eleventy:TemplateContent Having trouble rendering md template ./content/blog/post1.md: "{{ page.url | constructID(metadata.url, '') }}"
2025-08-27T14:57:45.127Z Eleventy:ComputedDataTemplateString Computed Data first pass data resolution error: TemplateContentRenderError: Having trouble rendering md template ./content/blog/post1.md at Template._render (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateContent.js:624:6) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async ComputedDataTemplateString.findVarsUsed (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedDataTemplateString.js:57:13) at async ComputedData.resolveVarOrder (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedData.js:74:17) at async ComputedData.setupData (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedData.js:104:3) at async Template.addComputedData (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Template.js:563:4) at async Template.getTemplates (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Template.js:733:4) at async TemplateMap.initDependencyMap (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateMap.js:376:18) at async TemplateMap.cache (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateMap.js:425:3) at async TemplateWriter._createTemplateMap (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateWriter.js:356:3) { originalError: Template render error: (./content/blog/post1.md) EleventyNunjucksError: Error in Nunjucks Filter `constructID` (undefined) at Object.handleError (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/runtime.js:227:12) at Template.root [as rootRenderFunc] (eval at _compile (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:17:14) at Template.render (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:454:10) ... 6 lines matching cause stack trace ... at async ComputedDataTemplateString.findVarsUsed (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedDataTemplateString.js:57:13) { lineno: 0, colno: 0, firstUpdate: false, Update: [Function: Update], [cause]: EleventyNunjucksError: Error in Nunjucks Filter `constructID` (undefined) at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:111:11) at Template.root [as rootRenderFunc] (eval at _compile (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:9:62) at Template.render (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:454:10) at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:435:10 at new Promise (<anonymous>) at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:434:11 at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Markdown.js:69:13 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async Template._render (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/TemplateContent.js:608:19) at async ComputedDataTemplateString.findVarsUsed (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Data/ComputedDataTemplateString.js:57:13) { originalError: Error: pathPrefix (String) is required in the `url` filter. at default (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Filters/Url.js:17:9) at Function.transformUrl [as applyBaseToUrl] (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Plugins/HtmlBasePlugin.js:44:9) at Context.constructID (file:///Users/entitygarden/git/eleventy_computed_3_1_2/_config/schemaOrg.js:8:29) at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/UserConfig.js:419:24) at Context.fn (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Benchmark/BenchmarkGroup.js:37:23) at Context.<anonymous> (file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:109:15) at Template.root [as rootRenderFunc] (eval at _compile (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:9:62) at Template.render (/Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/nunjucks/src/environment.js:454:10) at file:///Users/entitygarden/git/eleventy_computed_3_1_2/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:435:10 at new Promise (<anonymous>) } } }
2025-08-27T14:57:45.127Z Eleventy:ComputedData 'folder_js.0.url' accesses [] variables
2025-08-27T14:57:45.128Z Eleventy:ComputedData 'eleventyNavigation.key' accesses [] variables
2025-08-27T14:57:45.129Z Eleventy:ComputedData 'eleventyNavigation.parent' accesses [] variables
2025-08-27T14:57:45.129Z Eleventy:ComputedData 'eleventyNavigation.title' accesses [] variables
2025-08-27T14:57:45.129Z Eleventy:ComputedData 'markdown_file.0.@type' accesses [] variables
2025-08-27T14:57:45.129Z Eleventy:ComputedData 'markdown_file.0.@id' accesses [ 'page.url' ] variables
2025-08-27T14:57:45.130Z Eleventy:ComputedData 'markdown_file.0.name' accesses [] variables
2025-08-27T14:57:45.130Z Eleventy:ComputedData 'markdown_file.0.url' accesses [ 'page.url' ] variables
2025-08-27T14:57:45.130Z Eleventy:ComputedData 'markdown_file.0.headline' accesses [] variables
2025-08-27T14:57:45.130Z Eleventy:ComputedData 'markdown_file.0.abstract' accesses [] variables
2025-08-27T14:57:45.130Z Eleventy:ComputedData 'markdown_file.0.datePublished' accesses [] variables
2025-08-27T14:57:45.130Z Eleventy:ComputedData 'markdown_file.0.dateModified' accesses [] variables
2025-08-27T14:57:45.130Z Eleventy:ComputedData 'markdown_file.0.image' accesses [] variables
2025-08-27T14:57:45.130Z Eleventy:ComputedData 'markdown_file.0.author.@type' accesses [] variables
2025-08-27T14:57:45.131Z Eleventy:ComputedData 'markdown_file.0.author.@id' accesses [] variables
2025-08-27T14:57:45.131Z Eleventy:ComputedData Computed data order of execution: [ 'page.outputPath', 'folder_js.0.@type', 'page.url', 'folder_js.0.@id', 'folder_js.0.@id2', 'folder_js.0.name', 'folder_js.0.description', 'folder_js.0.url', 'eleventyNavigation.key', 'eleventyNavigation.parent', 'eleventyNavigation.title', 'markdown_file.0.@type', 'markdown_file.0.@id', 'markdown_file.0.name', 'markdown_file.0.url', 'markdown_file.0.headline', 'markdown_file.0.abstract', 'markdown_file.0.datePublished', 'markdown_file.0.dateModified', 'markdown_file.0.image', 'markdown_file.0.author.@type', 'markdown_file.0.author.@id' ]
Reproduction steps
- Check out GitHub Repo [email protected]:KajKandler/eleventy_computed_3_1_2.git
- Switch to branch js_failing_on_3_1_2
- Install the version of 11ty/eleventy you want to run with (I left all other dependencies on the latest)
- Look at the URLs '/blog/', '/blog/post1/', and '/blog/post2/' and see in the page content the issues as described above
Expected behavior
I'd expect the behavior not to change, and metadata.url
being defined in all constructs.
Reproduction URL
[email protected]:KajKandler/eleventy_computed_3_1_2.git
Screenshots
