How to Write a Sitemap According to Best Practices: Format, Size Limits, and Common Mistakes

Views:
Create Time: 2026/11/30
Sitemap Format, Size Limits, and Common Errors: Baidu allows a single file up to 10 MB, while Google allows up to 50 MB; both are limited to 50,000 entries. Field definitions, standard examples, and four common pitfalls are all covered here.

A poorly written sitemap is more troublesome than no sitemap at all—if a crawler receives a file with the wrong format, it may discard the entire file. The rules for this document aren’t complicated, but you must follow the platform’s standards; Baidu and Google have different limits.

I. Three Acceptable Formats for Submission

  • Standard XML: Most commonly used; organizes a list of URLs by protocol
  • Plain Text TXT: One URL per line, ideal for quick verification
  • Index File: Consolidate multiple sitemaps into a single entry point

UTF-8 is the most reliable encoding, and Baidu also accepts GBK; do not mix the two within the same file.

II. Size Limits: The Two Companies Are Different

This is the part that’s easiest to get wrong:

  • Baidu: A single sitemap must not exceed 10 MB and must contain no more than 50,000 URLs; the maximum size for index files is also 10 MB.
  • Google: A single sitemap must not exceed 50 MB (uncompressed) and must contain no more than 50,000 URLs; index files must also not exceed 50 MB or 50,000 sitemaps.

If the limit is exceeded, split the file and use an index file to link multiple sitemaps together. Don't force tens of thousands of pages into a single file.

III. What Does a Valid XML File Look Like?

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>https://www.example.com/products/a.html</loc>
        <lastmod>2026-11-20</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
</urlset>

Explanations of several fields:

  • loc: Page URL, required. Baidu’s guidelines require it to be 256 bytes or less; Google allows longer URLs, but in practice, the shorter the better.
  • lastmod: Last modified date, in the format yyyy-mm-dd. The content should only be updated when it’s actually changed; don’t set it to the current date every time it’s generated.
  • changefreq:更新频率,可选 always、hourly、daily、weekly、monthly、yearly、never
  • priority: Priority on a scale from 0.0 to 1.0, rounded to one decimal place

Let’s pour a little cold water on the last two fields: mainstream search engines generally don’t use them as ranking factors, and the “priority” field is virtually ignored. It won’t hurt to include them, but don’t expect adjusting the priority to boost a page’s ranking.

IV. Four Common Mistakes

  • Use relative paths in `loc`, or mix `http` and `https`
  • Include pages marked with "noindex," 404 pages, and search results pages as well
  • The file is located in a directory that requires a login to access, so the crawler cannot retrieve it.
  • The sitemap URL is blocked by "Disallow" in the robots.txt file

The purpose of a sitemap is to submit pages to web crawlers; the guidelines are merely the minimum requirement. What truly determines whether a page is indexed is whether it contains actual content.

For web design in Wuxi, turn to Zongye Technology.


Helping You Build an Outstanding "Internet Plus" Enterprise
Zongye Official Account