Skip to main content

Claude/ChatGPT Prompt to Add SEO Metadata and Sitemap to Next.js App Router

Add Next.js 15 App Router SEO — generateMetadata, OpenGraph, JSON-LD, dynamic sitemap.ts, robots.ts, and canonicals — with copy-ready code.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt makes the AI add a complete SEO layer to a Next.js 15 App Router project, returning copy-ready code rather than pseudocode. You set the [route], the [base_url], the [og_image], and the [schema_type]. It produces generateMetadata per route (including the dynamic [route]), OpenGraph and Twitter Card tags using your default share image, JSON-LD for [schema_type] via the Script component, a dynamic sitemap.ts, a robots.ts, and canonical URLs built from [base_url].

The structure works because SEO breaks quietly when metadata and sitemaps drift apart, and a wrong canonical splits ranking across duplicate URLs. By generating all six pieces together and tying canonicals to [base_url], the prompt keeps them consistent from the first deploy. [route] shows how a dynamic page generates its metadata, [og_image] becomes the default share image, and [schema_type] (like BlogPosting) determines the JSON-LD shape so search engines and crawlers read the right structured data.

When to use it

  • You're starting an App Router build and want the SEO layer wired from day one.
  • You need generateMetadata for dynamic routes with title and description fallbacks.
  • You want OpenGraph and Twitter Card tags with a consistent default share image.
  • You need JSON-LD structured data for a specific schema type.
  • You want a dynamic sitemap.ts and a sensible robots.ts pointing at it.
  • You keep getting canonical URLs wrong and splitting ranking across duplicate paths.

Example output

You get each file fenced and copy-ready with a note on where it lives in the app directory: generateMetadata per route including the dynamic [route] with title/description fallbacks; OpenGraph and Twitter Card tags using [og_image] as the default share image; JSON-LD for [schema_type] injected via the Script component; a sitemap.ts that resolves static and dynamic routes from data; a robots.ts with allow/disallow rules pointing at the sitemap; and canonical URLs built from [base_url] so duplicate paths don't split ranking.

Pro tips

  • Set [base_url] to your real production domain — canonicals are built from it, and a wrong value silently splits ranking across duplicate URLs, which is the hardest issue to spot post-launch.
  • Match [schema_type] to the page's actual content; BlogPosting and Product generate different JSON-LD, and the wrong type sends misleading structured data to crawlers.
  • Provide a real [og_image] path that exists and is the right dimensions, since a missing share image produces broken link previews.
  • Use a representative [route] so the dynamic generateMetadata pattern transfers cleanly to your other dynamic pages.
  • Verify the sitemap.ts resolves your dynamic routes from the same data source your pages use, so the sitemap never lists URLs that 404.
  • Validate the generated JSON-LD in a structured-data testing tool before trusting it; small schema mistakes are easy to miss by eye.

Frequently Asked Questions

Does this generate metadata for dynamic routes, not just static pages?
Yes. Deliverable 1 produces `generateMetadata` per route including the dynamic `[route]` you specify, with title and description fallbacks. The pattern is meant to transfer to your other dynamic pages, so pick a representative route as the example.
What schema types can the JSON-LD use?
Whatever you set in `[schema_type]`, such as `BlogPosting`. The generated JSON-LD shape follows that type, so match it to the page's real content. Using the wrong type sends misleading structured data to search engines and AI crawlers.
Why does the canonical URL matter so much here?
Canonicals are built from `[base_url]` and tell search engines which URL is authoritative when duplicate paths exist. A wrong canonical splits your ranking signal across duplicate URLs, and it is one of the hardest SEO problems to notice after a site is live.
Does it create both a sitemap and a robots file?
Yes. It generates a dynamic `sitemap.ts` resolving static and dynamic routes from data, plus a `robots.ts` with allow/disallow rules that points at the sitemap. Make sure the sitemap pulls dynamic routes from the same data source your pages use so it never lists URLs that 404.
Should I validate the output before shipping?
Yes. Validate the generated JSON-LD in a structured-data testing tool and confirm your `[og_image]` path exists at the right dimensions. Small schema errors and broken share images are easy to miss by eye but degrade search and social previews.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in React & Next.js Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support