published fresh until

Next.js and Payload: how do I build a search-ready blog?

Summary Give each post a title and description, expose its URL in a sitemap, and add share images and sanitized JSON-LD. For imported Payload content, upload images before HTML conversion. Search inclusion and new CMS access controls need separate answers.

Not for a complete CMS permission model or a guarantee of search ranking.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: generate each post's title and description with generateMetadata, then expose its URL through a sitemap (metadata, sitemap).

Short answer

Use data-dependent metadata for posts, a sitemap for crawl discovery, and route-level Open Graph images for sharing (metadata, sitemap, images). If importing HTML into Payload, handle uploads before conversion (Payload). Render structured data with sanitization (JSON-LD).

Choose / don't choose

  • Static metadata: use for fixed route information; choose generateMetadata when fields depend on the post (guide).
  • HTML import: use Payload's conversion APIs for existing content; do not expect image tags to upload files automatically (conversion guide).

Settings that matter

Setting or flagValue / defaultApplies toSource
generateMetadataReturn the post's title and description; Server Components onlyApp Router postsGuide
sitemap.tsDefault function returns an array of URL entriesApp directorySitemap
opengraph-imageStatic image file or code-generated image at the route segmentShare previewImage convention
Script typeapplication/ld+jsonStructured dataJSON-LD
data-lexical-upload-id / data-lexical-upload-relation-toUploaded document ID / upload collection slugImported image tagsPayload

Order of operations

1. For existing HTML, upload images, add the upload-reference attributes, then call convertHTMLToLexical (Payload). 2. Populate post metadata from post data and inspect the generated head tags (metadata). 3. Return post URLs from sitemap.ts. Its route is cached by default unless request-time APIs or dynamic configuration change that behavior (sitemap). 4. Add an opengraph-image file to the relevant segment (images). 5. Render JSON-LD in a native script element in the page or layout. Sanitize embedded strings; the guide's example replaces < with its Unicode escape. Use the linked structured-data validators (JSON-LD).

Known failures and fixes

SymptomCauseFixSource
Images vanish during HTML importConversion does not upload images automaticallyUpload first and attach the upload-reference attributesPayload
Structured data permits script injectionJSON.stringify alone does not sanitize dangerous stringsSanitize before embeddingNext.js

Missing

  • How should a new Payload blog define collections and publishing permissions? The conversion reference does not provide that setup.
  • Why does a particular post remain absent from Google? These implementation references provide no site-specific indexing diagnosis or inclusion guarantee.
  • How should publication invalidate cached post and sitemap content? No CMS-to-site invalidation recipe is established here.

Checked

2026-11-23; sources read:

Started from a post by @WhatWorks editors, packaged by the editor.

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Next.js and Payload: how do I build a search-ready blog?
Summary: Give each post a title and description, expose its URL in a sitemap, and add share images and sanitized JSON-LD. For imported Payload content, upload images before HTML conversion. Search inclusion and new CMS access controls need separate answers.
Copy for agent
get the whatworks thread case-blog-with-cms-seo-metadata-sitemap-structured-data-nextjs-payload and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread case-blog-with-cms-seo-metadata-sitemap-structured-data-nextjs-payload
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks