eleventy
eleventy copied to clipboard
Better error messaging for tabs versus spaces in YAML front matter
Describe the bug Hi, sorry for the double post. I added this to the Discussions board (https://github.com/11ty/eleventy/discussions/2118) thinking maybe I did something simple (and wrong ;) but I haven't seen any responses yet so perhaps it's a proper bug.
My first serverless test is failing because even though netlify.toml is created (once), the redirects are never added. I just have a blank netlify.toml file.
My config:
const { EleventyServerlessBundlerPlugin } = require("@11ty/eleventy");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyServerlessBundlerPlugin, {
name: "weather",
functionsDir: "./netlify/functions/"
});
};
Output from running npx eleventy:
[11ty] Writing _site/index.html from ./index.liquid
[11ty] Writing _site/weather/index.html from ./weather.liquid
[11ty] Serverless: 2 files bundled to ./netlify/functions/weather.
[11ty] Wrote 2 files in 0.04 seconds (v1.0.0-beta.8)
As I said, if I remove netlify.toml, it gets generated, but it's empty. My serverless function was created thoujgh.
Environment:
- OS and Version: [e.g. Windows/Mac/Linux] WSL
- Eleventy Version [via
eleventy --versionornpx @11ty/eleventy --version] 1.0.0-beta.8
So this turned out to be a tab in my front matter. I swear I remember Eleventy throwing errors (or messages) in the past when it detected a tab in front matter, so is it a bug that the error wasn't shown?
I had the same problem yesterday. I couldn't figure out why. I added the redirect manually.
It happened to me as well 😔
I got an error that wasn’t helpful. Tabs in the front matter caused it (indent before title):
---
eleventyComputed:
title: '{{ global.title }}'
layout: index.njk
permalink: index.html
---
Here’s the log
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] Cannot read properties of null (reading 'permalink') (via TypeError)
[11ty]
[11ty] Original error stack trace: TypeError: Cannot read properties of null (reading 'permalink')
[11ty] at TemplateBehavior.setRenderViaDataCascade (~/node_modules/@11ty/eleventy/src/TemplateBehavior.js:45:64)
[11ty] at Template.getTemplateMapEntries (~/node_modules/@11ty/eleventy/src/Template.js:995:19)
[11ty] at TemplateMap.add (~/node_modules/@11ty/eleventy/src/TemplateMap.js:62:36)
[11ty] at async Promise.all (index 5)
[11ty] at async TemplateWriter._createTemplateMap (~/node_modules/@11ty/eleventy/src/TemplateWriter.js:243:5)
[11ty] at async TemplateWriter.generateTemplates (~/node_modules/@11ty/eleventy/src/TemplateWriter.js:277:5)
[11ty] at async TemplateWriter.write (~/node_modules/@11ty/eleventy/src/TemplateWriter.js:324:23)
[11ty] at async Eleventy.executeBuild (~/node_modules/@11ty/eleventy/src/Eleventy.js:1108:13)
[11ty] at async Eleventy._watch (~/node_modules/@11ty/eleventy/src/Eleventy.js:707:24)
[11ty] at async watchRun (~/node_modules/@11ty/eleventy/src/Eleventy.js:955:9)
[11ty] Wrote 0 files in 0.02 seconds (v2.0.0-canary.12)
I wonder if it’s possible to allow tabs in the front matter, instead of throwing errors. I know, I know…
But it would make 11ty friendlier to any code style. Right now if you want to use tabs in your project, you have to mix them with spaces only for the front matter. Unfortunately, such a mix is impossible to configure or test via EditorConfig.