SEO AEO GEO
All posts
Technical

Next.js static export SEO checklist for Cloudflare Pages

A static Next.js site on Cloudflare Pages can be incredibly fast and SEO-friendly — but only if you configure metadata, sitemaps, trailing slashes, and structured data correctly.

1. Configure next.config for static export

Set output: 'export', trailingSlash: true, and images: { unoptimized: true }. Trailing slashes are required for Cloudflare Pages to serve /slug/index.html correctly.

2. Use the Metadata API

Export metadata from server components and generateMetadata for dynamic routes. Set metadataBase once in the root layout so Open Graph URLs resolve correctly.

3. Generate sitemap.ts and robots.ts

Both files run at build time. Use export const dynamic = 'force-static' in Next.js 15+ so they are included in the static export. Allow AI crawlers like GPTBot and ClaudeBot.

4. Add JSON-LD structured data

Include Organization, WebSite, BreadcrumbList, FAQPage, and Article schemas. Validate with Google Rich Results Test and Schema.org Validator.

5. Add /llms.txt

An /llms.txt file helps AI crawlers quickly understand your site, key pages, and licensing. It is becoming a standard signal for AI search visibility.

Frequently asked questions

Why use static export instead of server rendering?
Static export gives you pure HTML files, fastest possible Time to First Byte, and easy hosting on edge networks like Cloudflare Pages — perfect for content and marketing sites.
Does static export support dynamic routes?
Yes, if you use generateStaticParams to pre-render every dynamic route at build time. Unknown slugs can return a 404 with dynamicParams = false.
How do I add JSON-LD in Next.js App Router?
Render a script tag with type="application/ld+json" and dangerouslySetInnerHTML containing your schema object. Keep it in a reusable component for maintainability.