Image
ProjectsAboutResumeBlogDesign
Contact
Image
Brandon

Full stack EngineerFull stack Engineer

ProjectsAboutResumeDesignBlog3D StuffContact
Image

Blog

0 min read
Image from the movie Alien - from cosmos.com
MDX in NexJs

How to Export Metadata from MDX for Next.js SEO

Brandon Nolan

Brandon Nolan

February, 8, 2025

Next.js supports exporting a metadata object from your MDX files, which can be used to enhance SEO and social sharing features. This is especially useful for blog posts and documentation pages.

Example: Exporting Metadata

You can export a metadata object at the top of your MDX file like this:

export const metadata = {
  title: "How to Export Metadata from MDX for Next.js SEO",
  description:
    "A guide on exporting metadata from MDX files to leverage Next.js SEO features.",
  authors: [{ name: "Jane Doe", url: "https://janedoe.com" }],
  openGraph: {
    images: ["https://cdn.cosmos.so/example-image.jpg"],
  },
};

This metadata will be picked up by Next.js and can be used for SEO, Open Graph, and other meta tags.

Why Use Metadata in MDX?

  • SEO: Improve your page's search engine ranking with relevant titles and descriptions.
  • Social Sharing: Enhance how your content appears when shared on social media platforms.
  • Consistency: Keep your metadata close to your content for easier management.

Further Reading

  • Next.js Documentation: Metadata
  • MDX Documentation

This post demonstrates how to export metadata from MDX files for use with Next.js SEO features, inspired by leerob's site.

How is your experience so far?

ProjectsAboutResumeDesignBlog3D StuffContact BlogFreelanceLegacySite MapGithubLinkedin

Available
For
Work

© 2020 - 2025 Brandon Nolan. All Rights Reserved.

+1(437)-439-3888
Canada | Global