Error: Failed to parse front matter in file <path> – gray‑matter parsing in Eleventy
0 reputation · 31 Jul 2021, 00:46 UTC
0 reputation · 31 Jul 2021, 00:46 UTC
When Eleventy encounters invalid YAML in a file’s front matter, it logs the message “Error: Failed to parse front matter in file ” and skips writing that file’s output. In version 2.0 and later the build exits with a non‑zero status unless the --quiet flag is supplied, which can cause CI pipelines to fail even though other pages may still be generated.
The desired outcome is to retain the detailed error report for debugging while allowing the build to finish with a zero exit code so that only genuine failures halt the pipeline. It is unclear whether Eleventy provides a built‑in option or a plugin hook to treat front‑matter parse errors as warnings instead of fatal errors, or whether using --quiet suppresses only the exit code or also the error message.
--quiet?--quiet flag suppress the exit code only, or does it also hide the “Failed to parse front matter” message?35275 reputation · 31 Jul 2021, 04:58 UTC
Eleventy does not currently provide a built-in configuration flag or plugin hook to convert gray-matter parsing errors into non-fatal warnings. When a YAML syntax error occurs in the front matter, the build process treats it as a critical failure in version 2.0+.
The --quiet flag suppresses both the detailed error messages (including the file path and line number) and the non-zero exit code. Because it hides the diagnostic output, it is not recommended for CI pipelines where you still need to identify which file contains the invalid YAML.
Since Eleventy uses the gray-matter library, these errors are almost always caused by strict YAML specification violations. Common triggers include:
:), brackets, or dashes within a value without wrapping the entire string in quotes.--- sequence, which causes the parser to attempt to read the entire page content as YAML.To resolve the error while maintaining a healthy CI pipeline, you must fix the source data rather than suppressing the error. Use these steps to isolate the problematic file:
--quiet to capture the exact file path from the logs.title: "My Page: A Deep Dive".Diagnostic Detail Needed: If you are using a custom data cascade or an external .json/.js data file that feeds into the front matter, please specify, as the parsing logic differs from standard .md front matter.
Use comments to ask for clarification. Post a solution as an answer.
5,750 reputation · 31 Jul 2021, 04:24 UTC
In Eleventy 2.x and later, --quiet is a logging verbosity switch. It suppresses console output—including the “Failed to parse front matter” line—but it does not change the process’s exit status. The build still ends with a non‑zero code when a front‑matter parse error is encountered.
Eleventy does not expose a flag to turn a gray‑matter parse exception into a warning. The usual workaround is to run a YAML linter before the Eleventy build, or to supply a custom front‑matter engine that catches the exception and logs a warning while returning an empty data object.
const matter = require('gray-matter');
module.exports = function (content) {
try { return matter(content); }
catch (err) { console.warn('YAML error in file', err.path); return { data: {}, content }; }
};