Dynamic sitemaps, robots.txt and canonical URL management
Module 43: Wix Headless SEO | Lesson 495 of 688 | 46 min read
By Michael Andrews, Wix SEO Expert UK
When you go headless, Wix no longer generates your sitemap or manages your robots.txt. You must build these yourself using data from the Wix APIs. This lesson shows you how to create dynamic sitemaps, configure robots.txt and manage canonical URLs correctly.
Generating Dynamic XML Sitemaps from Wix Data
Your sitemap must include every indexable page on your headless frontend. This means querying the Wix CMS API, eCommerce API and Blog API to get all published URLs, then generating a valid XML sitemap that includes lastmod dates, changefreq hints and priority values.

Building a dynamic sitemap with Next.js and Wix
- Create a sitemap.xml route in your Next.js app (app/sitemap.xml/route.ts)
- Query the Wix CMS API for all published blog posts, pages and dynamic content
- Query the Wix eCommerce API for all published products and categories
- Combine all URLs with your custom domain prefix
- Include lastmod using the Wix lastUpdated field from each content item
- Generate valid XML using a sitemap library or template literal
- Submit the sitemap URL to Google Search Console
- Set up a cron job or webhook to regenerate the sitemap when content changes
Robots.txt Configuration for Headless Sites
Your robots.txt must allow Googlebot to access all public pages while blocking internal routes like API endpoints, preview pages and member-only areas. Place the robots.txt at your domain root and include a Sitemap directive pointing to your dynamic sitemap.
Canonical URL Management
With headless Wix, you must ensure canonical URLs point to your custom frontend domain, not to the Wix backend. Every page needs a self-referencing canonical tag. Paginated pages need proper rel="next" and rel="prev" hints. Product variants need canonicals pointing to the main product URL unless they have unique search intent.
Sitemap Index for Large Sites
If your headless Wix site has more than 50,000 URLs, split your sitemap into multiple files using a sitemap index. Create separate sitemaps for products, blog posts, categories and static pages. The sitemap index file references each sub-sitemap, making it easier for Google to process your full URL inventory.
How to Generate Dynamic Sitemaps for a Headless Wix Site
Follow this complete guide to build a production-ready dynamic sitemap that stays in sync with your Wix CMS content automatically.
Building and maintaining a dynamic XML sitemap for your headless Wix frontend
- In your Next.js App Router project, create the file app/sitemap.ts. This file exports a default async function that Next.js will call to generate your sitemap.xml at build time or on-demand.
- Import your Wix client from lib/wix-client.ts and import the blog, stores and data modules from the Wix SDK. You will query each of these to collect all indexable URLs.
- In the sitemap function, query your Wix Blog API using blog.listPosts() with pagination to fetch all published post slugs and their lastUpdated timestamps. Store these in an array of sitemap entry objects.
- Query your Wix eCommerce API using products.queryProducts() to fetch all published product slugs and their lastUpdated values. Add these to your sitemap array with the /products/ URL prefix.
- Query any Wix CMS dynamic collections using data.queryDataItems() for each collection that has public-facing pages. Map each item to its frontend URL using your routing convention.
- Define a static pages array containing your homepage, about, contact and any other manually created pages with their last modified dates hardcoded or read from a config file.
- Combine all arrays into a single sitemap entries array and return it from the sitemap function in the format Next.js expects: each entry as an object with url, lastModified, changeFrequency and priority fields.
- Set changeFrequency to "daily" for the homepage and blog index, "weekly" for product and blog post pages, and "monthly" for static pages. Set priority to 1.0 for the homepage, 0.8 for key landing pages, 0.6 for blog posts and 0.4 for secondary pages.
- For sites with more than 50,000 URLs, split your sitemap into multiple files by returning a sitemap index from app/sitemap.ts and creating separate app/blog-sitemap.ts and app/products-sitemap.ts files for each content type.
- After deploying, navigate to your live domain/sitemap.xml in a browser to verify the XML renders correctly. Then go to Google Search Console > Sitemaps and submit your sitemap URL. Check back after 24 hours to confirm Google has processed it without errors.
- Set up a Wix webhook (Dashboard > Settings > Webhooks) pointing to a Next.js API route that calls revalidatePath("/sitemap.xml") whenever content is published or updated, ensuring the sitemap stays current without manual rebuilds.
This lesson on Dynamic sitemaps, robots.txt and canonical URL management is part of Module 43: Wix Headless SEO in The Most Comprehensive Complete Wix SEO Course in the World (2026 Edition). Created by Michael Andrews, the UK's No.1 Wix SEO Expert with 14 years of hands-on experience, 750+ completed Wix SEO projects and 425+ verified five-star reviews.