Skip to Content
Configuration

Configuration

Blog-wide settings use the Config type and are usually created with createConfig in next-md-blog.config.ts. Pass that object as options.config to getBlogPost, getAllBlogPosts, and related SEO helpers so author resolution and URLs stay consistent.

createConfig(partial: Config): Config

Merges your values with defaults and normalizes siteUrl (falls back to process.env.NEXT_PUBLIC_SITE_URL or http://localhost:3000).

next-md-blog.config.ts
import { createConfig } from '@next-md-blog/core'; export default createConfig({ siteName: 'My Blog', siteUrl: process.env.NEXT_PUBLIC_SITE_URL ?? 'https://example.com', defaultAuthor: 'Default Author', twitterHandle: '@site', defaultLang: 'en', defaultOgImage: 'https://example.com/og-default.png', authors: [ { name: 'Ada Lovelace', url: 'https://example.com/ada', twitter: '@ada', }, ], alternateLanguages: { en: 'https://example.com/blog/my-post', fr: 'https://example.com/fr/blog/my-post', }, blogPostPathSegment: 'blog', blogIndexPath: '/blogs', organization: { logo: 'https://example.com/logo.png', sameAs: ['https://twitter.com/yoursite'], }, });

Config fields

FieldPurpose
siteNameSite / brand name in metadata and schema
siteUrlCanonical origin for URLs in Open Graph, RSS, sitemap helpers
defaultAuthorFallback when a post has no author in frontmatter
authorsRich Author[] used to resolve frontmatter names to bios, avatars, links
twitterHandleSite Twitter / X handle for card metadata
defaultOgImageFallback image when a post has none
defaultLangDefault language hint where applicable
alternateLanguagesMap of locale → URL for hreflang (metadata + sitemap); per-post frontmatter.alternateLanguages overrides
blogPostPathSegmentPath segment for default post URLs (default blog) when canonicalUrl is not set
blogIndexPathBlog listing path or absolute URL for default breadcrumbs and generateBlogListMetadata Open Graph URL (default {siteUrl}/blogs)
organizationOptional SiteOrganization: id, legalName, description, logo (image URL), sameAs (profiles) for JSON-LD publisher

loadConfig() and getConfig()

Both return default configuration (env-based siteUrl, default site name, etc.). They do not read next-md-blog.config.ts from disk. In App Router apps, import your config module and pass it explicitly:

import blogConfig from '@/next-md-blog.config'; await getBlogPost(slug, { config: blogConfig });

Some internal helpers call getConfig() when no config is passed; for predictable SEO and authors, always pass your createConfig result from the app.

Environment variables

  • NEXT_PUBLIC_SITE_URL — Recommended in production for correct canonical and OG URLs when you use createConfig without a hardcoded siteUrl.
Last updated on