How can I update sitemap file without losing the old URLs? In other words, does the Google search engine keep the old URLs indexed and add the new ones, or does it erase removed URLs?
Sitemaps don't have much to do with indexing or rankings. You could remove URLs from your sitemap or even remove your sitemap entirely without hurting your SEO.
- A sitemap isn't needed to get the pages on your site crawled and ranked. Googlebot will crawl your site from the home page even without a sitemap.
- Sitemaps can occasionally help Googlebot discover pages on your site that are not linked from other pages. Googlebot will crawl that page but usually it will decide not to index or rank it. To get pages indexed and ranked well, they really need to be linked from other pages.
- Google doesn't use several fields that can be added to sitemaps. The
priorityfields are just ignored. Googlebot comes back to crawl URLs based on how popular they are and how often Google has seen them change before.
- The biggest benefit of Sitemaps is providing extra data to you in Google Search Console.
- Google also uses sitemaps as a signal as to your preferred URLs. If you do have a sitemap you should ensure that it is clean.
- No duplicates
- No error URLs
- No redirecting URLs
For more information see The Sitemap Paradox.
If they are still valid, it will keep them. If they start returning error codes, then they will usually be removed.
If this is a case of having sitemaps from different applications, then Google will accept multiple sitemaps for the same website. An example of where I do this is on one of my product websites. I use Google's own scripts to periodically create a sitemap of the main static pages. The online documentation is created by Help&Manual - and this creates its own sitemap which I also submit to Google.
Large sites have too many pages to all be included in one sitemap file. As a result, it's normal to remove the last result of a sitemap when adding a new one. If you want to have every URL on your site in a sitemap, you can have multiple sitemaps with older pages.
Google discovers pages on your site through your sitemap when crawled. It is not necessary to have a sitemap on your website, nor is it necessary for all of your pages to be in a sitemap to stay indexed. Sitemaps are simply a way for Google to discover your pages that it hasn't discovered through links.