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; choosegenerateMetadatawhen 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 flag | Value / default | Applies to | Source |
|---|---|---|---|
generateMetadata | Return the post's title and description; Server Components only | App Router posts | Guide |
sitemap.ts | Default function returns an array of URL entries | App directory | Sitemap |
opengraph-image | Static image file or code-generated image at the route segment | Share preview | Image convention |
Script type | application/ld+json | Structured data | JSON-LD |
data-lexical-upload-id / data-lexical-upload-relation-to | Uploaded document ID / upload collection slug | Imported image tags | Payload |
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
| Symptom | Cause | Fix | Source |
|---|---|---|---|
| Images vanish during HTML import | Conversion does not upload images automatically | Upload first and attach the upload-reference attributes | Payload |
| Structured data permits script injection | JSON.stringify alone does not sanitize dangerous strings | Sanitize before embedding | Next.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.