Limitation for sitemap.xml size

Sitemaps should be no larger than 10MB (10,485,760 bytes) and can contain a maximum of 50,000 URLs. These limits help to ensure that your web server does not get bogged down serving very large files. This means that if your site contains more than 50,000 URLs or your Sitemap is bigger than 10MB, you must create multiple Sitemap files and use a Sitemap index file. You should use a Sitemap index file even if you have a small site but plan on growing beyond 50,000 URLs or a file size of 10MB. A Sitemap index file can include up to 1,000 Sitemaps and must not exceed 10MB (10,485,760 bytes). You can also use gzip to compress your Sitemaps.

Is there a way to create a multiple sitemap?

Currently no.

As someone who is looking to migrate to hugo, this is the biggest “missing” feature(I’m looking to migrate sites that have hundreds of thousands of pages).

The logic is fairly straightforward(I’ve never written a line of Go or I’d submit a pull request myself):


curpage_cnt = 0
sitemap_file_counter = 0
if(numpages >50k):
  for page in allpages:
    curpage_cnt += 1
    ...
    if(curpage_cnt % 50000 == 0):
      sitemap_file_counter += 1
      curpage_cnt = 0
    sitemap_file = "sitemap%s.xml.gz" % sitemap_file_counter
    ...

Then, sitemap.xml becomes a sitemap index that lists the all sitemap files generated above instead of pages.
https://support.google.com/webmasters/answer/75712

Is there any chance this is implemented in the foreseeable future? I would imagine others would value this as well…

I would be happy to give input or qa a proposed code branch if it would help, but would not trust myself to write acceptible Go code to implement.

Hi, i think with the custom output format you can create multiple sitemap. https://gohugo.io/extras/output-formats/

A post was split to a new topic: Please add limit the sitemap size