Skip to content
tezvyn:

How would you design an auto-generated sitemap.xml for a large blog?

Source: sitemaps.orgMediumHow cards are made

This tests scalable SEO automation. A strong answer proposes an async pipeline, sitemap index files past 50,000 URLs, and loc, lastmod, and priority. Red flag: manual edits, static files in git, or ignoring the 50,000 URL limit.

What's really being asked

This question evaluates whether you can design a production-ready system for automated sitemap generation at scale rather than treating a sitemap as a static artifact. The interviewer cares about your understanding of the sitemaps.org protocol limits, event-driven architecture, and how to guide search engine crawlers without over-promising behavior.

The full answer

First, an async generation pipeline triggered by CMS publish, update, or delete events rather than a nightly cron job, so the sitemap stays fresh without unnecessary rebuilds. Second, a sharding strategy: when the blog exceeds 50,000 URLs or the file nears 50MB, you must split entries across multiple sitemap files and reference them in a sitemap index file. Third, required and optional fields per sitemaps.org: every URL needs a loc tag with a fully qualified, properly URL-escaped and entity-escaped URI under 2,048 characters; lastmod should reflect the actual article modification date in W3C Datetime format; changefreq and priority are optional hints, not commands, with priority ranging from 0.0 to 1.0 relative to your own site. Fourth, hosting and delivery: the file must be UTF-8 encoded, placed at the root or a valid path, and served with a 200 OK so crawlers can fetch it reliably.

The mistakes people make

Treating changefreq or priority as direct instructions that force crawler behavior; they are hints and search engines may ignore them. Generating the sitemap manually or checking it into version control, which creates a maintenance bottleneck and stale data. Ignoring the 50,000 URL or 50MB limit and dumping every article into a single file. Using the sitemap generation timestamp instead of the actual article lastmod date. Failing to entity-escape ampersands or other XML special characters in URLs, which breaks XML parsing.

What usually comes next

How would you handle a multi-region site with hreflang variants in the sitemap? What is your strategy if a sudden bulk import adds 100,000 articles at once? How do you verify the sitemap is valid and monitor whether search engines are actually consuming it? Would you use a static file, an API endpoint that streams XML, or a hybrid approach?

A concrete example

Consider a blog with 80,000 articles. You maintain a database table tracking article_id, canonical_url, updated_at, and is_published. On publish or update, an event triggers a worker that regenerates the affected sitemap shard. Articles are ordered by updated_at and split into two sitemap files of 40,000 URLs each, referenced by a sitemap index at example.com/sitemap_index.xml. Each url entry contains loc with the canonical HTTPS URL, lastmod in YYYY-MM-DD format derived from the articles updated_at column, changefreq set to weekly for active blogs, and priority set to 0.5 for posts and 1.0 for the homepage category landing pages. The worker writes the files to object storage and purges the CDN cache so search engines always receive the latest version.

Interview question

Which approach best describes a production-ready sitemap design for a blog with 80,000 articles?

  • a.Trigger an async worker on CMS publish/update events to regenerate only affected sitemap shards, split entries across multiple files under a sitemap index when exceeding 50,000 URLs, and use each article's actual modification date for lastmod.Correct
  • b.Build an on-demand API endpoint that queries all published articles and dynamically generates a single sitemap XML response with no caching layer.
  • c.Maintain a single sitemap.xml containing all 80,000 URLs, setting changefreq to daily and priority to 1.0 to ensure search engines crawl every article frequently.
  • d.Store the sitemap as a static file in version control, regenerate it in a nightly cron job, and use the file generation time for every lastmod entry.
Why?

Option A is correct because it respects the 50,000 URL limit via sharding and a sitemap index, keeps the sitemap fresh with event-driven updates, and uses accurate per-article lastmod values as required by the protocol. Option B is a tempting distractor because dynamic generation sounds modern, but serving 80,000 unsharded URLs on-demand breaks protocol limits and creates a performance bottleneck.

Just read this? Test yourself on what you have been reading.

Read the original → sitemaps.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles