Why a Next.js sitemap lives in your code
If your company site in Tashkent or Samarkand is built on Next.js, there is no “generate sitemap” button anywhere. The framework renders pages, while the list of URLs for search engines is something the developer defines. It is a little more work upfront, but the sitemap is built from the same data as the site itself, so it stays in sync with what is really published.
For a business this matters because Google and Yandex discover new pages faster when they appear in sitemap.xml. For an online store with a catalogue, or a blog that grows week by week, the sitemap is a working tool rather than a formality.
The built-in approach in App Router
In App Router you add a special sitemap file (usually sitemap.ts) to the app folder. It exports a function that returns an array of objects. Each object holds a page URL, a last-modified date and, optionally, change frequency and priority. The framework turns the array into valid XML and serves it at /sitemap.xml.
On the older Pages Router, teams usually build a separate route that assembles XML by hand, or use a package that generates the file at build time. That still works, but if you are migrating to App Router, the built-in mechanism is the better target.
The core rule: the sitemap must read from the same data source as your routes. Blog posts, products and service cards come from a database, a headless CMS or content files, and the sitemap function queries the same place. A new publication then appears without anyone editing a list by hand.
What to include and what to leave out
Static pages such as the homepage, services and contacts can be listed directly. Dynamic pages are fetched from your data source. Take published records only, since drafts and items awaiting moderation do not belong in the file.
- Skip pages marked noindex.
- Skip URLs with parameters, filters and sorting.
- Exclude technical routes: API, login, account area, draft previews.
- Remove URLs that redirect elsewhere or return 404.
- If you take payments through Click or Payme, keep cart and checkout pages out.
Dates, freshness and large sites
Put the real update date from your database or CMS into the last-modified field. A common mistake is using the current time for every URL. Search engines then see the whole site “changing” daily and stop trusting the field.
Freshness depends on the rendering mode. If the sitemap is generated statically at build time, a new article shows up only after the next deploy. For a blog with one post a week, that is enough. For a catalogue where products appear and disappear daily, use dynamic generation with caching, or set a revalidation interval.
A single sitemap file has protocol limits on the number of URLs and on file size. For large sites, Next.js lets you split the sitemap with the generateSitemaps function, which returns a list of IDs and produces one file per ID, for example articles in one and products in another. Submit all parts, or an index file, in Search Console and Yandex Webmaster.
Russian and Uzbek versions in one sitemap
Most business sites in Uzbekistan run in at least two languages. Sitemap entries can carry alternate language URLs, which mirrors the hreflang tags in your page code and helps search engines connect the Russian and Uzbek versions. Make sure both versions exist and return a 200 status, and that the sitemap hreflang matches what the pages declare.
robots.txt and the base URL trap
The robots file is created the same way, through robots.ts in the app folder. It points to your sitemap.xml and sets rules for technical routes. Confirm that staging and preview domains are closed to indexing while the production domain is open. Mixed-up environments are a frequent reason a site drops out of search.
The second trap is the domain. It is usually read from an environment variable. If that variable is missing on the production server, the sitemap fills up with localhost or a hosting provider's technical domain, and search engines discard those URLs. After every major deploy, open the sitemap and glance at the first lines.
How to verify it, and what comes next
The check takes a few minutes and can save weeks of waiting on indexing. Open /sitemap.xml on the live domain, confirm the URLs are absolute and use the right domain, test the response code on a few of them, publish a test entry to see it appear, then submit the sitemap to Search Console and Yandex Webmaster and read the processing status.
If a Next.js site is indexed worse than expected, the sitemap and robots file are the first things to inspect. They are only one part of technical SEO, though: speed, meta tags, URL structure and content matter too. If you need SEO optimisation in Uzbekistan, the markdev team can audit your project and tell you what to fix first. Describe your task and we will talk through the options.
FAQ
Do I need a package for a Next.js sitemap?
In App Router usually not. A sitemap file in the app folder that returns a list of URLs is enough. Packages are more common on the Pages Router.
Why do new pages not show up in my sitemap?
The sitemap is probably generated statically at build time. It will update after the next deploy, or you can switch to dynamic generation or set a revalidation interval.
What if localhost appears in my sitemap?
Check the environment variable that holds your site address on the production server. It is likely missing or pointing to a test domain. Fix it and rebuild.
Should Russian and Uzbek pages be listed separately?
You can list each version as its own entry or declare alternate language URLs inside one entry. Either way, the URLs must return 200 and match the hreflang on the pages.
Let’s look at your task for free
Leave your contact — in a 15-minute call we’ll show where leads get lost and what to fix first.