Skip to main content
If you cannot click the Publish button in the editor and hovering over it shows the Fix invalid MDX before publishing error tooltip, at least one page on your branch has MDX that fails to parse. The editor blocks publishing until every page on the branch parses successfully. This keeps broken syntax from reaching your live site. The tooltip tells you how many pages have errors. The same error blocks Request review on feature branches. Common causes include:
  • An unclosed component tag, such as a <Note> without a matching </Note>.
  • Malformed JSX in the page body, such as an unclosed brace in an expression.
  • Frontmatter that isn’t valid YAML, such as inconsistent indentation or an unclosed quote.
While a page has invalid MDX or invalid frontmatter YAML, those edits stay local to you. Teammates editing the same page only receive valid content, so a syntax error you introduce doesn’t overwrite their work. See Collaborate in the editor for how real-time editing handles invalid content.

Find the affected page

If the tooltip reports one broken page, it’s usually the page you’re editing. If it reports more than one, or you don’t know which page has the error, check each page you’ve changed on the branch:
  1. Click Publish in the toolbar to open the publish menu. The menu lists every changed file on your branch.
  2. Open each changed file in turn and look for parsing errors in source mode (see below). Pages that parse successfully render normally. The broken page shows the error.

Fix the error manually

  1. Open the affected page in the editor.
  2. Switch to source mode with Cmd + Shift + S (macOS) or Ctrl + Shift + S (Windows). Source mode highlights the invalid MDX and shows the parsing error.
  3. Fix the syntax. Once the page parses, the error clears and the Publish button becomes available again.
For frontmatter errors, check that every value is valid YAML: quote strings that contain colons or special characters, keep indentation consistent, and close every quote. See Page metadata for the supported frontmatter fields.

Fix the error with the agent

  1. Open the editor panel.
  2. Prompt the agent to fix any invalid MDX or frontmatter YAML. Without a mention, the agent uses the page you have open as its initial context. To fix errors across the branch in one prompt, ask the agent to find and repair every page with invalid MDX. See Agent.