SEO & feeds
Next.js metadata files (recommended)
The @next-md-blog/cli can generate these three files for you on a full init (when blog pages are enabled), or anytime via the seo subcommand—use --force to overwrite existing files. Paths are under app/ or src/app/, whichever exists in your project.
You can also add them by hand. Use Next.js metadata file conventions so /sitemap.xml and /robots.txt are served automatically.
app/sitemap.ts(orsrc/app/sitemap.ts) —export default async function sitemap()returninggetBlogSitemap(posts, blogConfig)from@next-md-blog/core/next(or the same export from@next-md-blog/core).app/robots.ts—export default function robots()returninggetBlogRobots(blogConfig).app/feed.xml/route.ts— RSS; usecreateRssFeedResponse(validPosts, blogConfig)from@next-md-blog/core/nextinstead of hand-rolling headers (the CLI scaffolds this route by default).
Merge static routes with blog URLs in sitemap.ts if needed (spread or concat arrays).
Next.js page metadata
generateBlogPostMetadata(post, config?)— title, description, Open Graph, Twitter cards, robots from frontmatter,alternates.languagesfromfrontmatter.alternateLanguages(per-post) orconfig.alternateLanguages, with relative URLs resolved againstsiteUrl.generateBlogListMetadata(posts, config?)— listing metadata; Open Graph URL usesconfig.blogIndexPathor{siteUrl}/blogs.
Pass your createConfig result as config everywhere.
JSON-LD
generateBlogPostSchema(post, config?, options?)—BlogPosting(orfrontmatter.type) with authors, dates, publisherOrganization(stable@id, optionalconfig.organizationlogo /sameAs/ legal name), word count, andtimeRequired.generateOrganizationSchema(config?)— standaloneOrganizationscript forlayout.tsx(same@idas the article publisher whensiteUrlmatches).generateBlogPostSchemaGraph(...)— one@graphpayload (Organization + article with publisher by@id+ breadcrumbs).generateBreadcrumbsSchema— default trail: Home → Blog (blogIndexPathor{siteUrl}/blogs) → post. Override withbreadcrumbsorBlogPostSEO.BlogPostSEO— setasGraphfor a single@graphscript instead of two separate tags.
Render with BlogPostSEO or serialize into <script type="application/ld+json">.
Hreflang and sitemap alternates
frontmatter.alternateLanguages— per-postRecord<string, string>(hreflang code → URL). Overridesconfig.alternateLanguagesfor that post. Relative values are expanded withsiteUrlin metadata and sitemap output.getBlogSitemapEntries/getBlogSitemapsetalternates.languagesfor Next’s sitemap format (Next serializes hreflang in/sitemap.xml).
For multi-locale routes (e.g. /[locale]/blog/[slug]), use per-post canonicalUrl and alternateLanguages (see Internationalization) and aggregate all locale posts in sitemap.ts.
RSS
generateRSSFeed(posts, config?)— RSS 2.0 XML string; capped byRSS_POST_LIMIT(20). PrefercreateRssFeedResponse(posts, config?)from@next-md-blog/core/nextinapp/feed.xml/route.ts.
URL configuration
| Mechanism | Role |
|---|---|
canonicalUrl (frontmatter) | Canonical post URL for metadata, JSON-LD, RSS, sitemap |
config.blogPostPathSegment | Default segment instead of blog when canonicalUrl is omitted |
config.blogIndexPath | Blog listing URL for default breadcrumbs and list metadata |
Security and plugins
Custom rehype/remark plugins in MarkdownContent can change HTML output. Prefer well-maintained plugins and review output for user-controlled markdown.