
Coding in Public
Jun 9, 2025
Fix Your Sitemap with Next.js + Framer
In my last article, I showed you how to fix canonical URLs when running Framer for marketing pages with Next.js for your app. But there's another integration detail that'll bite you if you're not careful: your sitemap.
The Sitemap Dilemma
When you're using Framer for marketing pages (/, /contact-us, /about
) and Next.js for your app (/app/*
), where does your sitemap live? And more importantly, how do you make sure search engines can find it?
Here's what most developers miss: your sitemap needs to be served from your root domain, but it also needs to include all your marketing pages that are actually hosted on Framer.
The Simple Solution
The fix is surprisingly straightforward. Create a static sitemap.xml file in your Next.js public folder:
The Next.js Config Magic
The key is in your next.config.js
. You need a specific rewrite rule that catches the sitemap request before your Framer fallback:
Notice the order matters:
First, we explicitly handle
/sitemap.xml
to serve it from Next.jsThen we handle blog routes
Finally, we have the catch-all that excludes
sitemap.xml
and sends everything else to Framer
Why This Works
The magic is in that last rewrite rule: (?!sitemap.xml
). This negative lookahead ensures that sitemap requests don't get forwarded to Framer. Instead, they're served directly from your Next.js public
folder.
When Google crawls https://respondra.com/sitemap.xml, it gets served from your Next.js app, but all the URLs in the sitemap point to your marketing pages, which are seamlessly handled by your Framer rewrite rules.
Testing Your Sitemap
First, verify the technical setup:
Visit
https://respondra.com/sitemap.xml
in your browserCheck that you see your clean XML without any Framer interference
Run
curl -I https://respondra.com/sitemap.xml
to verify it returns proper headers
The Google Search Console Setup
Here's where most developers fumble the handoff. You've got your sitemap working, but now you need to tell Google about it properly.
Step 1: Property Setup Matters
Make sure you have the correct property set up in Google Search Console. You want the property for respondra.com
(without www), not www.respondra.com
. This should match your canonical URLs from the previous article.
If you currently have the www version as your main property:
Add the non-www version as a new property
Verify ownership using the HTML tag method or DNS verification
Set the non-www version as your preferred domain
Step 2: Submit Your Sitemap
In Google Search Console:
Navigate to Sitemaps in the left sidebar
Click Add a new sitemap
Enter
sitemap.xml
(just the filename, not the full URL)Click Submit
Google will start processing it immediately. You should see it appear in the sitemaps list with a status of "Success" within a few minutes.
Step 3: Handle the Old Sitemap
If you previously had a sitemap submitted from your Framer setup (like www.respondra.com/sitemap.xml
), you need to clean this up:
Find the old sitemap in your sitemaps list
Click on it and select Delete sitemap
This prevents confusion and ensures Google focuses on your new, correct sitemap
Step 4: Monitor the Results
Within 24-48 hours, check the sitemap performance:
Click on your new sitemap in the list
You should see "Discovered" and "Indexed" counts
All 6 URLs should show as discovered (this happens quickly)
Indexed count will grow over the following days as Google crawls
Common GSC Issues and Fixes
"Couldn't fetch" error: Your rewrite rules might not be working. Test the sitemap URL directly in an incognito browser.
"Has issues" status: Click into the details. Usually this means duplicate URLs or redirect chains. Make sure your canonical URL fixes from the previous article are working.
Low indexed count: Be patient. Google doesn't index everything immediately, especially if these are new URLs or your domain is relatively new.
Pro Tip: Use the URL Inspection Tool
After submitting your sitemap, test a few URLs:
Copy one of your marketing page URLs from the sitemap
Use the URL Inspection tool in GSC
Paste the URL and hit Enter
You should see "URL is on Google" or "URL can be indexed"
If you see issues here, it usually means your canonical URL setup needs work.
The Edge Case Most Miss
Here's what's clever about this setup: your sitemap lives in Next.js, but it references pages that are served by Framer. When Google crawls these URLs from your sitemap, they get seamlessly routed through your rewrite rules to Framer.
This means you get the best of both worlds - centralized sitemap control in your Next.js app, but all your marketing pages still benefit from Framer's speed and design capabilities.
Why This Matters
Without this setup, you'd either have:
No sitemap (Google finds your pages slowly)
Framer's default sitemap with wrong canonical URLs
A sitemap that doesn't include your app routes
With this simple fix, search engines get a clear map of your entire site structure, served from the right domain, pointing to the right URLs.
The Real 5% Edge
Most developers running hybrid setups completely forget about the sitemap until they notice their pages aren't getting indexed properly. By handling this upfront, you ensure search engines can efficiently crawl and index your entire site.
This is exactly the kind of detail that compounds over time. Six months from now, when your marketing pages are ranking well and your app pages are properly indexed, you'll be glad you took the extra 10 minutes to get this right.
Next up: I'll show you how to handle analytics tracking across your hybrid setup. Because yes, there's another integration detail that most people miss.
Have you run into sitemap challenges with your setup? Let me know in the comments. These edge cases are where we learn the most about building robust integrations.
Blog