withastro/astro · warning
[${id}] Astro now supports MDX! Support for components in ".
Error message
[${id}] Astro now supports MDX! Support for components in ".md" (or alternative extensions like ".markdown") files using the "setup" frontmatter is no longer enabled by default. Migrate this file to MDX. What it means
The markdown plugin inspects frontmatter while transforming a .md file: if a `setup` key exists it warns that the legacy feature — embedding components/scripts in markdown via setup frontmatter — is no longer enabled by default, and directs you to MDX, which supports components natively. The file still compiles as plain markdown.
Source
Thrown at packages/astro/src/vite-plugin-markdown/index.ts:125
} = renderResult.metadata;
// Add default charset for markdown pages
const isMarkdownPage = isPage(fileURL, settings);
const charset = isMarkdownPage ? '<meta charset="utf-8">' : '';
// Resolve all the extracted images from the content
const localImagePaths: MarkdownImagePath[] = [];
for (const imagePath of rawLocalImagePaths) {
localImagePaths.push({
raw: imagePath,
safeName: shorthash(imagePath),
});
}
const { layout } = frontmatter;
if (frontmatter.setup) {
logger.warn(
'markdown',
`[${id}] Astro now supports MDX! Support for components in ".md" (or alternative extensions like ".markdown") files using the "setup" frontmatter is no longer enabled by default. Migrate this file to MDX.`,
);
}
const code = `
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent, maybeRenderHead } from ${JSON.stringify(
astroServerRuntimeModulePath,
)};
import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
${layout ? `import Layout from ${JSON.stringify(layout)};` : ''}
${
// Only include the code relevant to `astro:assets` if there's images in the file
localImagePaths.length > 0 || remoteImagePaths.length > 0
? getMarkdownCodeForImages(localImagePaths, remoteImagePaths, html)
: `const html = () => ${JSON.stringify(html)};`
}View on GitHub (pinned to 52e6c34790)
Solutions
- Rename the file from .md to .mdx and replace the setup frontmatter with real MDX imports/exports at the top of the file
- Remove the setup frontmatter entirely if it is unused
- Audit content collections for schema changes once files become .mdx
Example fix
# before src/content/blog/post.md
---
setup: |
import Banner from '../../components/Banner.astro';
---
<Banner />{/* rendered only with legacy .md component support */}
# after src/content/blog/post.mdx
import Banner from '../../components/Banner.astro';
<Banner /> Defensive patterns
Strategy: validation
Validate before calling
# CI gate: no legacy `setup` frontmatter left in markdown files
grep -rl --include='*.md' -E '^setup:' src/ && { echo 'migrate .md setup frontmatter to .mdx'; exit 1; } || true Prevention
- Adopt .mdx for any markdown that needs components or script
- Codemod legacy content during major upgrades instead of keeping legacy behavior alive
- Lint content-collection frontmatter keys via a schema
When it happens
Trigger: A .md (or .markdown) page/content file whose YAML frontmatter contains `setup:`, processed during dev or build. The plugin keys the warning off frontmatter.setup regardless of whether the setup code referenced Astro components.
Common situations: Projects dating to Astro 1/2 that used component-enhanced markdown; content authors copying old templates; after an upgrade, components in .md files silently stop rendering because the legacy pipeline is gone.
Related errors
- [MDX] A remark or rehype plugin attempted to inject invalid
- ${colors.bold(plugin)} not applied.
- To inherit Markdown plugins in MDX, please use explicit impo
- [MDX] A Sätteri plugin attempted to inject invalid frontmatt
- InvalidFrontmatterInjectionError
AI-assisted analysis of withastro/astro@52e6c34790 (2026-08-18).
Data as JSON: /api/errors/7e1a735438ed5717.
Report an issue: GitHub.