At Saarza, we handle the sitemap in a fully automated, code-driven way that eliminates manual updates entirely.
Our entire list of published blog posts is maintained in a single, central constants file within the codebase. Whenever we add, update, or remove a post, we simply modify that one file—no dashboards, no external tools, no separate XML editing.
Next.js (using the App Router) provides a special built-in file called sitemap.ts. This file runs automatically at build time and whenever the site is requested, generating a fresh sitemap.xml on the fly.
Here’s how it works under the hood:
- The sitemap file directly imports the central posts list from our constants.
- It loops through every post to create the corresponding blog URL entries, automatically pulling the correct slug and publication date to set the “last modified” timestamp.
- It then combines these dynamic blog entries with a small set of fixed static pages (like the homepage and services page).
- The result is a complete, up-to-date sitemap that includes accurate URLs, modification dates, change frequency, and priority scores—all served directly to search engines like Google.
Because the posts list is the single source of truth, any change to it instantly propagates to the sitemap the next time the site builds or the sitemap endpoint is accessed. There’s no risk of forgetting to update an XML file, no extra deployment steps, and no latency from database queries.
This approach keeps our SEO infrastructure self-healing: as long as the constants file is accurate, the sitemap is always correct, ensuring search engines can discover and index our content reliably with zero ongoing manual effort.