Blog / Technical Guides
Add a Sitemap and robots.txt to a Lovable Site
By Keyona Meeks, Founder, ReRev Labs · Oct 31, 2026 · 7 min read
The short answer: A sitemap is a file that lists the pages you want search engines to find. A robots.txt file tells crawlers which addresses they may fetch, and can point to the sitemap. For a Lovable site, you need both as plain files at the root of your site. This post gives a small script that writes the sitemap from a list of pages, tested with a mock, and a minimal robots.txt. Google calls a sitemap submission "merely a hint," and says robots.txt "is not a mechanism for keeping a web page out of Google." I could not read Lovable's documentation or Search Console help, so I give no Lovable or Search Console click paths. We sell build work, so weigh this with that in mind.
By the end of this post, you'll be able to:
- Say what a sitemap and a robots.txt each do.
- Generate a sitemap file from a list of pages.
- Write a robots.txt that points to it.
- Check both files as a crawler would see them.
I sell build work. The facts about Google come from two of its pages, read as excerpts on October 31, 2026. The examples from rerev.io come from our own repo and our live site on the same day.
What does a sitemap do?
Google's page on building a sitemap says "All formats limit a single sitemap to 50MB (uncompressed) or 50,000 URLs." It says "Use fully-qualified, absolute URLs in your sitemaps." On whether to bother, it says "submitting a sitemap is merely a hint," and the sentence goes on to say it does not guarantee that Google will use it for crawling. Source: Build and submit a sitemap, read through a tool that returns excerpts. The list of supported formats was paraphrased by that tool, so I do not quote it. On where to put the file, the page says "You can host your sitemaps anywhere on your site," and recommends the site root.
So: a sitemap helps, it does not promise, and a small site with good links between pages may do fine without one. I have no data on how much it helps a small site.
What does robots.txt do?
Google's introduction to robots.txt says "A robots.txt file tells search engine crawlers which URLs the crawler can access on your site." It also says the file "is not a mechanism for keeping a web page out of Google." That second sentence was an excerpt of a longer one. Source: Introduction to robots.txt. The page, as the tool returned it, gave no rules about where the file must live, so I could not confirm that from this page. The root of the site is where I would expect it, and where our own file sits.
Do not use robots.txt to hide anything private. A page that must stay private needs real access control.
What does a sitemap file look like?
Here is the shape, from our own live sitemap on October 31, 2026:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>https://www.rerev.io/</loc><lastmod>2026-10-30</lastmod></url>
<url><loc>https://www.rerev.io/services</loc><lastmod>2026-10-30</lastmod></url>
</urlset>
Each page is a url with a loc, which is the full address, and an optional lastmod, which is a date. I did not read the sitemap protocol page, so I am describing what our file does, not the full specification.
How do you generate it?
Keep a list of your pages and let a script write the file. This one is for Node. Change the site address and the list.
// Writes sitemap.xml from a list of paths. Run with: node sitemap.js
const fs = require('fs');
const SITE = 'https://www.example.com';
const ROUTES = ['/', '/services', '/blog/first-post'];
const TODAY = new Date().toISOString().slice(0, 10);
function esc(s) {
return String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
}
function buildSitemap(site, routes, lastmod) {
const rows = routes.map(function (r) {
return ' <url><loc>' + esc(site + r) + '</loc><lastmod>' + lastmod + '</lastmod></url>';
});
return '<?xml version="1.0" encoding="UTF-8"?>\n' +
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' +
rows.join('\n') + '\n</urlset>\n';
}
if (require.main === module) {
if (ROUTES.length > 50000) { throw new Error('Too many URLs for one sitemap'); }
fs.writeFileSync('public/sitemap.xml', buildSitemap(SITE, ROUTES, TODAY));
}
module.exports = { buildSitemap };
It writes public/sitemap.xml, so the folder public must exist. It stamps every page with today's date, which is a shortcut: the date says "checked today," not "changed today." For a better signal, store a real date per page.
What did the test cover?
I ran it with a Node harness and checked it with node --check. The checks: the XML declaration is present, the root address is correct, an ampersand in a path is escaped, three routes make three url entries, and lastmod appears. I also ran it for real and parsed the output with a Python XML parser, which read it without error. All five checks passed. That tests the file's shape. It does not test that Google accepts it, and I did not run anything in Google or Lovable.
What does a minimal robots.txt look like?
User-agent: *
Allow: /
Sitemap: https://www.example.com/sitemap.xml
That allows everything and points to the sitemap. Our own live robots.txt has a Sitemap: line for each of the files it lists and several rules per crawler. Yours may be much simpler. Only add a Disallow: line for an address you do not want fetched, and remember what Google says about what robots.txt cannot do.
Where do the files go on a Lovable site?
In our repo, which is a Vite project, robots.txt sits in the public folder and is served from the site root. That is how Vite projects commonly work. I could not confirm how Lovable's own editor handles files, so ask Lovable, or whoever deploys your site.
How do you check both files?
Fetch them as a crawler would:
curl -s https://www.example.com/robots.txt
curl -s https://www.example.com/sitemap.xml | head
Look for the right content, not an HTML page. Some hosts may return the home page for a missing file, though I have not tested that here. If the first lines look like a web page where the XML should be, the file is not being served.
I ran both commands against our own site on October 31, 2026 and got the expected content back.
To tell Google about the sitemap, Search Console has a place for it. I could not read its help pages in this session, so I give no click path. Look up the current steps.
Where does an LLM fit in this?
An LLM can help with the messy part: reading your site structure and listing which pages should and should not be in the sitemap, or explaining a robots.txt you inherited. A person should check the list, because an LLM can leave out a page or include a private one. The script and the checks are plain rules, and they do the same thing every time. My stance: AI writes the code, plain automation runs it, and an LLM shows up only where the input is messy and a person checks the result. For crawlers more broadly, see making your Lovable website AI-crawler friendly.
Where this has limits
- I read two Google pages as excerpts. Check the live pages.
- I did not read the sitemap protocol, Lovable's documentation or Search Console help. I give no Lovable or Search Console click paths.
- The script was mock-tested, not run in Google or Lovable.
- Today's date as
lastmodis a shortcut. - robots.txt is not a privacy tool.
- I have no data on how much a sitemap helps a small site.
- We sell build work. Read this with that in mind.
- No ReRev prices and no promises about results.
If you want help with this on your site, or want to claim a free rebuild of a tool you pay for, tell us what you use. Do not send passwords or login details.
Frequently asked questions
Does a Lovable site need a sitemap?
It can help. Google calls submitting one "merely a hint." A small, well-linked site may be found without one.
What is the size limit for a sitemap?
Google's page says a single sitemap is limited to 50MB uncompressed or 50,000 URLs.
Does robots.txt hide a page from Google?
No. Google says it is not a mechanism for keeping a web page out of Google.
Where does the sitemap file go?
Google recommends the root of your site. Check how your host serves files.
How do I check that the files are served?
Fetch them with curl and read the first lines. A web page where the XML should be means the file is not served.
How do I tell Google about my sitemap?
Search Console has a place for it. I could not confirm the click path.
Read next: Connect a Lovable site to Search Console is where you submit the sitemap this post creates.