Skip to content

Add sitemap.xml and robots.txt with canonical URLs#36

Draft
baanish wants to merge 1 commit intomainfrom
cursor/sitemap-robots-canonical-830f
Draft

Add sitemap.xml and robots.txt with canonical URLs#36
baanish wants to merge 1 commit intomainfrom
cursor/sitemap-robots-canonical-830f

Conversation

@baanish
Copy link
Copy Markdown
Owner

@baanish baanish commented Apr 18, 2026

Summary

Adds Next.js App Router metadata routes so the static export publishes /sitemap.xml (valid Sitemaps 0.9 XML) and /robots.txt with a Sitemap: line pointing at the absolute sitemap URL.

Details

  • src/lib/site/canonical-base.ts: resolves the public origin from NEXT_PUBLIC_SITE_URL, SITE_URL, then VERCEL_URL, else http://localhost:3000 for local builds; applies NEXT_PUBLIC_BASE_PATH so subpath deploys get URLs like https://host/base/ and https://host/base/sitemap.xml.
  • src/app/sitemap.ts / src/app/robots.ts: export const dynamic = "force-static" required for output: "export".
  • src/app/layout.tsx: sets metadataBase from the same helper so relative metadata URLs resolve consistently.
  • Docs: README, docs/deployment.md, and docs/architecture.md mention NEXT_PUBLIC_SITE_URL for production canonical URLs.

Verification

npm run check passed locally.

Notes for deployers

Set NEXT_PUBLIC_SITE_URL (e.g. https://agent-render.com) in the static host build environment so sitemap/robots use the live domain instead of localhost / preview host.

Open in Web Open in Cursor 

- Add Next.js metadata routes (force-static for static export)
- Resolve site origin via NEXT_PUBLIC_SITE_URL, SITE_URL, or VERCEL_URL
- Include base path in loc URLs when NEXT_PUBLIC_BASE_PATH is set
- Set layout metadataBase for consistent canonical metadata
- Document SITE_URL in README, architecture, and deployment docs

Co-authored-by: Aanish Bhirud <baanish@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5fb4ae0e-67db-4766-a12a-deccaa6f829a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/sitemap-robots-canonical-830f

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying agent-render with  Cloudflare Pages  Cloudflare Pages

Latest commit: eaa780b
Status: ✅  Deploy successful!
Preview URL: https://ace11649.agent-render.pages.dev
Branch Preview URL: https://cursor-sitemap-robots-canoni.agent-render.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants