Skip to Content
Configuration

Configuration

Configuration splits into two layers:

  1. SiteConfig — site-wide identity (name, URL, default author, Organization JSON-LD).
  2. CollectionConfig — one per content surface (blog, glossary, docs…). References the shared site.

Both are created with type-narrowing helpers.

defineSite(config: SiteConfig): SiteConfig

next-md-blog.config.ts
import { defineSite } from '@next-md-blog/core'; export const site = defineSite({ siteName: 'My Blog', siteUrl: process.env.NEXT_PUBLIC_SITE_URL ?? 'https://example.com', defaultAuthor: 'You', twitterHandle: '@you', defaultLang: 'en', organization: { legalName: 'Your Company, Inc.', logo: 'https://example.com/logo.png', founder: 'Ada Lovelace', foundingDate: '2020-01-01', address: { addressLocality: 'Paris', addressCountry: 'FR' }, contactPoint: { email: 'hi@example.com', contactType: 'customer support' }, sameAs: ['https://twitter.com/example'], wikidata: 'https://www.wikidata.org/wiki/Q12345', }, });

SiteConfig fields

FieldPurpose
siteNameSite / brand name. Used in <title> suffixes, OG, Organization.name
siteUrlCanonical origin, no trailing slash
defaultAuthorFallback when a post has no author in frontmatter
authorsRich Author[] for resolving names → profiles
twitterHandleTwitter Card site/creator
defaultOgImageFallback OG image when a post has none
defaultLangDefault inLanguage
organizationRich Organization JSON-LD (founder, foundingDate, address, contactPoint, sameAs, wikidata)

defineCollection<T>(config: CollectionConfig<T>): Collection<T>

next-md-blog.config.ts
import { defineCollection } from '@next-md-blog/core'; export const blog = defineCollection({ id: 'blog', contentDir: 'content/blog', pathSegment: 'blog', site, }); export const glossary = defineCollection({ id: 'glossary', contentDir: 'content/glossary', pathSegment: 'glossary', schemaType: 'DefinedTerm', rss: false, site, });

CollectionConfig fields

FieldPurposeDefault
idStable identifier (cache key, log messages)required
contentDirFilesystem folder, relative to cwdrequired
pathSegmentURL segment under /{lang}required
siteShared SiteConfigrequired
labelHuman label (breadcrumbs, RSS title fallback)capitalized pathSegment
indexPathListing URL used in breadcrumbs and sitemap/{pathSegment}
schemaTypeSchema.org @type for each doc'BlogPosting'
schemaBuilderOverride the entire JSON-LD builderoptional
rssRSS feed config; pass false to disableenabled with sane defaults
defaults.titleTemplate'site-suffix' (default), 'absolute', or 'bare''site-suffix'
defaults.speakableDefault speakable JSON-LD specoff

Built-in schema builders

schemaTypeBuilder behavior
BlogPosting (default) / Article / NewsArticle / TechArticleFull Article schema with publisher, dates, author, image, speakable, isPartOf (series), E-E-A-T fields
DefinedTermGlossary-friendly schema with termCode + inDefinedTermSet referencing the collection index

For any other schemaType, pass a schemaBuilder callback:

defineCollection({ id: 'recipes', contentDir: 'content/recipes', pathSegment: 'recipes', site, schemaBuilder: (doc, ctx) => ({ '@context': 'https://schema.org', '@type': 'Recipe', name: doc.frontmatter.title, url: ctx.url, inLanguage: ctx.locale, // ... }), });

Environment variables

  • NEXT_PUBLIC_SITE_URL — recommended in production for correct canonical and OG URLs.
Last updated on