If you write MDX for a website inside Obsidian, the preview you get by default is not the page you will publish. This article explains what it takes to make an Obsidian preview match the live rendering, and which checks are worth running before a page leaves your vault. It is written for authors and developers who keep content in Obsidian and publish to a static site.
Why is a normal Markdown preview not enough for MDX?
An ordinary Markdown preview treats the file as plain text. MDX is different: < and { are code, the frontmatter drives a layout, and the site may expose its own components. Miss any of those and the preview quietly disagrees with the published page.
The practical fix is to reuse the site’s own pipeline rather than approximate it. Vergo MDX Studio compiles each note with the same @mdx-js/mdx compiler the site build runs and enables GFM, so tables and the exact error positions match.
How do you make the preview match the published page?
Two things have to be reused, not reimplemented: the compiler and the layout.
- Compile the note with the site’s compiler to get the same HTML, including how it handles expressions and components.
- Render that HTML into a small rebuild of the site’s entry page — title, Quick answer, tags, table of contents and FAQ taken from the frontmatter.
- Apply the site’s stylesheet, and set direction from the
langfield so RTL and LTR are correct.
The plugin does this in a side pane. Because the layout is rebuilt from the same frontmatter keys the site reads, the Quick-answer box, tags and FAQ appear in the preview exactly where they will appear after approval.
What can you check before a page is published?
Preview is only half of it. The useful second half is a pre-flight check that runs the rules a dashboard would run, so nothing broken reaches the server.
| Check | Why it matters |
|---|---|
| Title 30–60 characters | Longer titles are truncated in results |
| Summary 70–165 characters | It becomes the Quick answer and the meta description |
| No H1 in the body | The title is already the page’s H1 |
| Image alt text | Empty alt fails basic accessibility |
lang is en or fa |
Drives direction and the language switch |
| Media exists in the vault | A missing file blocks sending |
The same page also reports MDX compile errors with the exact line and column, and explains the two most common causes: a < that MDX reads as a tag, and a { that MDX reads as a JavaScript expression.
How should media be handled before sending?
Collect every local reference — Markdown images, HTML src and poster, and the image frontmatter key — hash each file by content, and upload only what the server does not already have. Keeping names content-addressed means the same image is never uploaded twice, and the page can reference a stable /media/studio/<hash>.<ext> URL.
What should you remember?
- Make an accurate MDX preview by reusing the site’s compiler and layout, not by approximating them.
- Keep a bundled stylesheet so the preview works offline and never renders unstyled.
- Run length, alt-text, H1, language and media checks before sending anything.
- Hash media by content and upload only what the server lacks.
- Treat sending as a submission for approval, not a publish.
To see the tool that puts this together, read about Vergo MDX Studio. You can also see more about the author and the site or browse the rest of the journal.