Getting Started
The fastest way to get started with Gatsby + MDX is to use the MDX
starter. This
allows you to write .mdx files in src/pages
in order to create new pages on
your site.
🚀 Quick start
Initialize the MDX starter with the Gatsby CLI
npx gatsby new my-mdx-starter https://github.com/ChristopherBiscardi/gatsby-starter-mdx-basic
Run the dev server by changing directory to the scaffolded site and install dependencies
cd my-mdx-starter/ npm install gatsby develop
Open the site running at http://localhost:8000!
Update the MDX content by opening the
my-mdx-starter
directory in your code editor of choice and editsrc/pages/index.mdx
. Save your changes and the browser will update in real time!
Add MDX to an existing Gatsby site
If you already have a Gatsby site that you’d like to add MDX to, you can follow these steps for configuring the gatsby-mdx plugin:
Add
gatsby-mdx
and MDX as dependenciesyarn add gatsby-mdx @mdx-js/mdx @mdx-js/react
If you’re upgrading from v0, check out the MDX migration guide.
Update your
gatsby-config.js
to use thegatsby-mdx
plugingatsby-config.jsmodule.exports = { plugins: [ // .... `gatsby-mdx`, ], }
Restart
gatsby develop
and add an.mdx
page tosrc/pages
What’s next?
Go check out the writing MDX guide to find out what else you can do with Gatsby and MDX.
Edit this page on GitHub