Front Matter

Front Matter Node

Overview

This node processes input text containing YAML front matter and extracts its structured data, the raw front matter block, and the remaining content. It is useful for workflows that need to parse markdown files or documents with embedded metadata (such as blog posts, documentation pages, or configuration files). For example, you can use this node to extract title, date, tags, and body content from a markdown file before further processing or storage.

Properties

Name Type Meaning
Text String The input text containing front matter.

Output

The node outputs an array of items, each with a json object containing:

  • data: An object representing the parsed front matter key-value pairs.
  • matter: A string containing the raw front matter block (including delimiters).
  • content: The main content of the text after removing the front matter.
  • text: The original input text.

Example output:

{
  "data": {
    "title": "My Post",
    "date": "2024-06-01"
  },
  "matter": "---\ntitle: My Post\ndate: 2024-06-01\n---",
  "content": "This is the body of the post.",
  "text": "---\ntitle: My Post\ndate: 2024-06-01\n---\nThis is the body of the post."
}

Dependencies

  • Uses the external npm package gray-matter for parsing front matter.
  • No special n8n configurations or environment variables are required.

Troubleshooting

  • Empty or Invalid Input: If the "Text" property is empty or does not contain valid front matter, the data and matter fields may be empty or missing expected keys.
  • Parsing Errors: If the input text contains malformed YAML in the front matter, parsing may fail or produce unexpected results. Ensure your front matter syntax is correct.
  • Common Error Messages:
    • "Cannot read property 'data' of undefined": This may occur if the input is not a string or is empty. Make sure to provide valid text input.

Links and References

Discussion