{"record":{"id":"2b86a8051e90ee23","repo":"mjmlio/mjml","slug":"an-mj-head-element-add-an-unkown-head-attribute","errorCode":null,"errorMessage":"An mj-head element add an unkown head attribute : ${attr} with params ${Array.isArray(params) ? params.join('') : params}","messagePattern":"An mj-head element add an unkown head attribute : (.+?) with params (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mjml-core/src/index.js","lineNumber":795,"sourceCode":"      if (Array.isArray(globalData[attr])) {\n        globalData[attr].push(...params)\n      } else if (Object.prototype.hasOwnProperty.call(globalData, attr)) {\n        if (params.length > 1) {\n          if (isObject(globalData[attr][params[0]])) {\n            globalData[attr][params[0]] = {\n              ...globalData[attr][params[0]],\n              ...params[1],\n            }\n          } else {\n            // eslint-disable-next-line prefer-destructuring\n            globalData[attr][params[0]] = params[1]\n          }\n        } else {\n          // eslint-disable-next-line prefer-destructuring\n          globalData[attr] = params[0]\n        }\n      } else {\n        throw Error(\n          `An mj-head element add an unkown head attribute : ${attr} with params ${\n            Array.isArray(params) ? params.join('') : params\n          }`,\n        )\n      }\n    },\n  }\n\n  globalData.headRaw = processing(mjHead, headHelpers)\n\n  content = processing(mjBody, bodyHelpers, applyAttributes)\n\n  if (!content) {\n    throw new Error(\n      'Malformed MJML. Check that your structure is correct and enclosed in <mjml> tags.',\n    )\n  }\n","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/mjmlio/mjml/blob/6c01d35af5da14108b86bbf052232e99de7ca755/packages/mjml-core/src/index.js#L777-L813","documentation":"During mjml2html, mj-head elements register attributes into globalData (fonts, styles, attributes, etc.). If an element passes an attribute (attr) that is not in the allowed head-attribute map, mjml2html throws this Error, naming the attribute and its params, and rendering aborts with no HTML output.","triggerScenarios":"Rendering a template containing an mj-head child (or custom component) that calls the head attribute handler with an unregistered attr — e.g. a typo like <mj-fonts>, an unknown/custom head element, or a component emitting an attribute not registered via registerComponent's head handling.","commonSituations":"Typos in head tags; custom components added to mj-head without registering their head attributes; version mismatches where a head attribute was renamed/removed; copying templates between MJML versions.","solutions":["Correct the head element/attribute name in the template to a supported one (mj-attributes, mj-style, mj-font, mj-breakpoint, mj-preview, mj-title)","Register the custom component so its head attributes are known to mjml-core","Check the attribute and params values in the message to pinpoint the offending tag","Align MJML package versions (mjml-core vs custom components) so registered attributes match the template"],"exampleFix":"// before\n<mj-head><mj-titel>Hi</mj-titel></mj-head>  // typo, throws\n// after\n<mj-head><mj-title>Hi</mj-title></mj-head>","handlingStrategy":"try-catch","validationCode":"const ALLOWED_HEAD = new Set(['mj-attributes','mj-style','mj-font','mj-breakpoint','mj-preview','mj-title'])\nfor (const child of head.children) {\n  if (!ALLOWED_HEAD.has(child.tagName)) throw new Error(`Unknown head element: ${child.tagName}`)\n}","typeGuard":"const isKnownHeadAttr = (attr, known) => typeof attr === 'string' && known.has(attr)","tryCatchPattern":"try {\n  const { html, errors } = mjml2html(mjml)\n} catch (e) {\n  if (String(e.message).startsWith('An mj-head element add an unkown head attribute')) {\n    // surface the attribute name from e.message and fail fast with a clear template error\n  }\n  throw e\n}","preventionTips":["Check head tag spelling (mj-title, mj-preview, mj-style, etc.)","Register custom components before rendering templates that use them","Keep mjml-core and custom component versions in sync","Lint MJML templates against the set of registered head attributes"],"tags":["mjml","validation","unknown-attribute","mj-head","rendering"],"backgroundTag":"unknown-head-attribute","analyzedSha":"6c01d35af5da14108b86bbf052232e99de7ca755","analyzedAt":"2026-09-02T21:31:03.649Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}