How do I create a sitemap.xml?
Last checked 31 Aug 2026
Short answer
Ask Lovable to generate a sitemap.xml listing your public routes and place it in the public folder, or ask for a dynamically generated one if your pages come from a database.
Static sites: the simple case
If your project has a fixed, known set of pages (home, about, pricing, contact), ask Lovable:
Create a sitemap.xml in the public folder listing all my public pages, with their URLs, and add it as a static file served at /sitemap.xml.
A basic sitemap entry looks like:
<url>
<loc>https://yourdomain.com/pricing</loc>
<lastmod>2026-08-01</lastmod>
</url>
Wrap all entries in a <urlset> root element with the standard sitemap XML namespace — Lovable knows this format and will produce valid XML if asked directly.
Dynamic sites: pages generated from data
If you have pages per blog post, product or listing pulled from your database, a static file quickly goes out of date. Instead:
Add a server function that queries [table] and generates sitemap.xml dynamically, including every published [post/product], and serves it at /sitemap.xml.
This needs a server function (Lovable Cloud or your connected Supabase project) that runs a query and outputs XML on request, rather than a fixed file.
Steps either way
- Decide which routes are genuinely public and worth indexing — exclude admin, auth or account pages.
- Ask Lovable to generate the file or endpoint.
- Confirm it's reachable at
https://yourdomain.com/sitemap.xmlafter publishing. - Reference it in
robots.txt(see how do I create robots.txt). - Submit it in Google Search Console.
What usually goes wrong
- Including private/auth-gated routes that Google shouldn't index.
- A static sitemap left un-updated for months while new pages are added — check it periodically or move to a dynamic version.
- Invalid XML (missing namespace, unescaped characters in URLs) causing Search Console to reject it — validate with a sitemap checker if it's rejected.
Related
Sources
Was this answer helpful?
Related questions
- AnswerHow do I connect Google Search Console?Use Lovable's Google Search Console integration to verify your domain and manage search data directly from chat, or verify manually by adding the DNS/HTML verification record Google provides.
- AnswerHow do I add schema markup?Ask Lovable to add JSON-LD structured data (schema.org markup) relevant to your page type — e.g. Organization, Product, Article or FAQ — inserted as a script tag in the page head.
- AnswerDoes Lovable automatically create a sitemap?No — a sitemap.xml isn't generated automatically for a typical project. You need to ask Lovable to add one, or it may be included as part of a dedicated SEO setup/review feature on newer projects.
- AnswerHow do I stop a Lovable page being indexed?Ask Lovable to add a noindex meta tag to that specific page, and optionally disallow it in robots.txt — don't block the whole domain by mistake.
You might also need
- GuideHow to Set Up SEO for a Lovable ProjectTitles, descriptions, canonical URLs, Open Graph and structured data — the technical SEO baseline every project needs.
- GuideHow to Generate a Dynamic SitemapServe an XML sitemap that updates itself as you publish new content, instead of a static file that goes stale.