Skip to Content
Content & frontmatter

Content & frontmatter

Files and location

  • Posts live under a directory at the project root, default name posts (constant POSTS_DIR_NAME).
  • Supported extensions: .md and .mdx.
  • The slug is the filename without extension (e.g. hello-world.md → slug hello-world).

Override the directory with GetBlogPostOptions.postsDir (path relative to process.cwd() is resolved inside getPostsDirectory).

Frontmatter (BlogPostFrontmatter)

Parsed with gray-matter . Known fields:

FieldTypeNotes
titlestringDisplay / SEO title
datestringUsed for sorting lists (newest first) and dates in metadata
descriptionstringMeta description
authorstring, object with name, or array of thoseNormalized with config authors
authorsArray of strings or { name } objectsSame normalization
tagsstring[]Keywords / article tags
ogImagestringCustom Open Graph image URL
imagestringFeatured image; fallback for OG
robotsstringRobots meta directive
noindexbooleanSEO helper flags
nofollowbooleanSEO helper flags
readingTimenumberMinutes; if omitted, computed from body
schemaobjectMerged into generated JSON-LD (see below)

Additional keys are allowed ([key: string]: unknown) and remain on frontmatter.

Metadata and schema resolution also look at optional aliases such as seoTitle, seoDescription, excerpt, publishedDate, modifiedDate, canonicalUrl, category, lang, imageAlt, and type (Schema.org @type, default BlogPosting). These are read in seo-metadata, seo-schema, and feed helpers where applicable.

Custom JSON-LD merge

If frontmatter.schema is a plain object, generateBlogPostSchema merges it on top of the generated BlogPosting object so you can add or override fields.

BlogPost vs BlogPostMetadata

  • BlogPost — full document: slug, content, frontmatter, readingTime, wordCount, authors (normalized).
  • BlogPostMetadata — listing shape: slug, frontmatter, authors (no content).

getAllBlogPosts returns BlogPostMetadata[], sorted by frontmatter.date descending (string compare).

Markdown rendering

MarkdownContent uses react-markdown with GFM and emoji remark plugins by default. Pass remarkPlugins / rehypePlugins only from trusted packages; custom plugins can change HTML output and security characteristics.

defaultMarkdownComponents exports the default element map used by MarkdownContent; you can merge overrides via the components prop.

Last updated on