Skip to content
Every tutorial here is 100% free — and always will be
LSLovableStudent

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

  1. Decide which routes are genuinely public and worth indexing — exclude admin, auth or account pages.
  2. Ask Lovable to generate the file or endpoint.
  3. Confirm it's reachable at https://yourdomain.com/sitemap.xml after publishing.
  4. Reference it in robots.txt (see how do I create robots.txt).
  5. 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.

Sources

Was this answer helpful?

Related questions

Website made, maintained and hosted by PromptSites.com

PromptSites logo