Configuration
Configuration splits into two layers:
SiteConfig— site-wide identity (name, URL, default author, Organization JSON-LD).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
| Field | Purpose |
|---|---|
siteName | Site / brand name. Used in <title> suffixes, OG, Organization.name |
siteUrl | Canonical origin, no trailing slash |
defaultAuthor | Fallback when a post has no author in frontmatter |
authors | Rich Author[] for resolving names → profiles |
twitterHandle | Twitter Card site/creator |
defaultOgImage | Fallback OG image when a post has none |
defaultLang | Default inLanguage |
organization | Rich 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
| Field | Purpose | Default |
|---|---|---|
id | Stable identifier (cache key, log messages) | required |
contentDir | Filesystem folder, relative to cwd | required |
pathSegment | URL segment under /{lang} | required |
site | Shared SiteConfig | required |
label | Human label (breadcrumbs, RSS title fallback) | capitalized pathSegment |
indexPath | Listing URL used in breadcrumbs and sitemap | /{pathSegment} |
schemaType | Schema.org @type for each doc | 'BlogPosting' |
schemaBuilder | Override the entire JSON-LD builder | optional |
rss | RSS feed config; pass false to disable | enabled with sane defaults |
defaults.titleTemplate | 'site-suffix' (default), 'absolute', or 'bare' | 'site-suffix' |
defaults.speakable | Default speakable JSON-LD spec | off |
Built-in schema builders
schemaType | Builder behavior |
|---|---|
BlogPosting (default) / Article / NewsArticle / TechArticle | Full Article schema with publisher, dates, author, image, speakable, isPartOf (series), E-E-A-T fields |
DefinedTerm | Glossary-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