Before you launch a multilingual Next.js site, check one thing: for each language, which address opens which page, and which language does that address tell search engines it serves? If you cannot answer that from a single place in your codebase, the setup is not finished yet. Routing rules, hreflang tags and sitemap files written separately tend to drift apart, and a small change in one can quietly break the others. This article turns the broader picture from our guide on technical infrastructure for global reach into concrete decisions for the Next.js side.
Write the locale structure down first
Before touching any code, write a short document. It should name the languages you will publish, the market each language serves, the default language, and the address format each language will use. This document becomes the single source of truth for the setup. If route files, the hreflang generator and the sitemap scripts all read from it, adding a language or removing one becomes a change in one place rather than a search through the project.
The most common mistake at this stage is hard-coding the language list in several places. One file lists en and tr, another file still lists only the original two, and a third file has a leftover value from an old experiment. These mismatches rarely show up in local development, where you usually open one language at a time. They tend to appear after publication, in search engine reports, or when a visitor in a market you thought was covered lands on a page in the wrong language.
It also helps to record a short decision for each language. Note who owns the content in that language, whether the translation is done by an agency or an in-house team, and which pages will be translated first. Keeping these content decisions next to the technical ones makes later corrections easier to scope, because you can see at a glance which pages depend on which translation work.
Setup checklist
Work through the seven steps below in order. Write down the output of each step before moving to the next one, even if the output is only a sentence. The detailed guidance for each step follows in the sections below.
- Define the language list in one configuration source.
- Decide whether the default language lives at the root or under its own prefix.
- Fix the URL pattern for each language in a table.
- Build the language switcher so it links to the matching page in the other language.
- Generate hreflang tags from translation groups, not by hand.
- Produce one sitemap per language and list them in an index file.
- Keep slugs meaningful in each language and add permanent redirects when a slug changes.
Language and prefix decisions
1. Define the language list in one source
Keep language codes, display names, the default language and the target market for each language in a single module. That module can be a constant array, a JSON file or a database table. What matters is that routing, sitemap generation and hreflang generation all read the same source. Use one consistent format for codes. A lowercase BCP 47 style, such as tr or en, keeps comparisons and file paths predictable. If you ever introduce regional variants such as en-GB or en-US, make sure your matching code treats them deliberately rather than by accident.
Before you enable a new language, confirm that it has content worth publishing, because thin language versions give search engines little to evaluate.
2. Choose the default language and prefix
Decide once whether the default language sits at the root address or under its own prefix. Both approaches can work. What you must avoid is two different addresses that serve the same content without one pointing to the other as the preferred version. If / and /en show the same page, one of them should be the canonical address and the other should be handled consistently.
Hiding the default language prefix keeps the home address short. Showing a prefix for every language makes each language look like a clearly separate section of the site. Whichever you choose, apply the same rule to internal links, the language switcher and the sitemap, so that the address a visitor sees is the same address the crawler finds.
Next.js offers more than one way to handle locale detection and routing, and the configuration approach has changed over time. Check the current official documentation for your framework version to confirm which file, option and middleware pattern applies to your project. The concepts in this article hold regardless of the exact API, but the names of settings and file conventions may differ from what you remember.
3. Fix the URL patterns in a table
The table below shows the address pattern for each language. It is a template. The default language sits at the root, English uses the /en/ prefix, and a new language follows the same pattern with its own code. The slug in each row is generated for that language and does not need to match the slugs of other languages word for word.
| Language | Home page | Blog post | Note |
|---|---|---|---|
| Turkish (default) | / | /blog/tr-slug | No prefix; this can be the canonical address |
| English | /en | /en/blog/en-slug | The slug is chosen for English search behaviour |
| Any new language | /code | /code/blog/code-slug | Same template, added to the language list |
Generate every address in the table from one helper function. The helper takes a language code and a page identifier, then returns the full path. Building addresses by concatenating strings inside page components spreads the rules across the project. When the prefix logic lives in one function, a change to that rule touches one file, and your tests can check that function directly.
Translation, hreflang and sitemaps

4. Build the language switcher
The language switcher should send the visitor to the matching page in the other language. Sending every visitor to the other language's home page is simpler to build, but it breaks the reading context and often leads to a second search from the start. To make the matching possible, each page needs to know the address of its translation. Store that link as a translation group identifier shared by all language versions of the same page. The switcher and the hreflang tags can then both be generated from the same data.
What should the switcher show when a page has no translation? There is no single correct answer. Some sites hide the option, others send the visitor to the home page of the target language. The important part is to avoid a broken link or a page that appears to be a translation but is not. Decide the behaviour in writing and apply it to every page type, including category pages, product pages and articles.
Automatic redirects based on the browser language can help a first-time visitor, but they can also affect how crawlers reach each language version. Keep such logic limited, run it only on the first visit, and always let an explicit language choice from the visitor take priority. Check the current search engine guidance on language-based redirects in the official sources, because the recommendations may be updated over time.
5. Generate hreflang from one map
Each page's hreflang tags should list every language version of that page. The list should also include an x-default entry that points to the version you want used when no language fits. Write a function that reads the translation group and returns the full set of tags, rather than typing tags into individual pages. When a language version is removed from the group, the tags on the remaining pages update with it.
Hreflang relationships need to be reciprocal. If page A points to page B, page B must point back to page A. Single-direction tags are not treated as reliable signals. When you test a group of pages, check that each tag has a matching tag on the other page. The exact rules and examples are described in the current official search documentation, so use that as the reference when the details matter.
Use absolute URLs in the tags, including the protocol and the domain. Relative paths can be read differently across domains, staging environments and caching layers. Build the full address with one helper, so that the scheme and host come from the same configuration as the rest of the site. For the content side of the same problem, our article on multilingual content SEO covers how pages in each market should be planned.
6. Produce one sitemap per language
A separate sitemap for each language makes maintenance easier and lets you see how many pages in each language are being discovered. Place the individual sitemaps under a sitemap index at the root. Every address inside a language sitemap should be the absolute URL of that language version. The Turkish sitemap lists /blog/... addresses, and the English sitemap lists /en/blog/... addresses. Before a page enters a sitemap, confirm that it returns a 200 status and does not sit at the end of a redirect chain.
Escape XML characters carefully. An ampersand in a query string, which is common in image URLs from stock photo services, must be written as an escaped entity. Without that, the file can become invalid, and the problem may only appear after the sitemap has been broken for some time. Passing generated files through an XML parser before publication catches this class of error early.
Per-language sitemaps also make updates lighter. When one language gains new content, you regenerate only that language's file. In Search Console, you can then follow each language sitemap as its own entry and compare the number of submitted and discovered pages. Check the official Search Console documentation for how those reports are defined.
Slugs per language
7. Keep slugs meaningful in each language
Each language's slug should make sense in that language. Rather than translating the Turkish slug word for word into English, choose the phrase that people in that market would actually type into a search box. The result is easier to read and often fits the search habits of the audience better. Because the translation group links the language versions, the slugs can differ without breaking the hreflang relationship.
If you need to change a slug after publication, add a permanent redirect from the old address to the new one. Set up the redirect for that language only, and leave the other language's address alone. Test the redirect in a real browser after each change, and check the sitemap for the old address, which should be removed. A slug change also affects the link in the translation group, so confirm that the other language's switcher still points to the right page.
Different slugs per language also make it easier for a content owner in each market to edit their own address without involving other teams. That flexibility becomes more useful as the number of languages grows. Still, record each change, including the date and the old and new addresses. When a link breaks months later, that record shortens the diagnosis considerably.

Avoiding redirect loops when switching language
The most disruptive setup error is a redirect loop that appears when the visitor changes language. A rule that detects the browser language and a cookie that stores the visitor's choice can end up sending the same request back and forth. The browser then gives up, and the visitor sees an error page. Search engine crawlers can hit the same loop and fail to index the page at all.
We cover the symptoms, the common causes and the testing methods in detail in our article on redirect loops when switching language. This section summarises the points that matter most for a Next.js setup.
Three rules remove most of the risk. First, keep the language choice in one place and read it the same way for both the cookie and the address. Second, let automatic detection run only on the first visit, so that later page transitions respect the visitor's choice. Third, make the switcher link go directly to the matching page, without an intermediate redirect step.
After each change to the routing logic, measure how many redirects a language switch produces in a browser. If you see more than one hop, review the detection rule and the cookie logic together, because the problem usually sits where the two meet. Repeat the check in a private window and in a clean browser profile, since old cookies can hide the issue during testing.
Pre-publication checks
Run the same checklist for every language before you publish. The checks below cover most of the setup, and you should repeat them after each change to routing, translations or sitemap generation.
- Does the home page and at least one blog post in each language return a 200 status with the correct language attribute?
- Does the language switcher send the visitor to the matching page in the other language?
- Are the hreflang tags reciprocal, and does each page include an x-default entry?
- Does each language sitemap list only absolute addresses for that language?
- Does an old slug reach the new address through a single permanent redirect?
- Does a language switch in a browser complete without a redirect loop?
Scripts loaded on every language version also affect speed, and a slow language version can damage the experience in one market without showing up in your main test. Our note on how third-party scripts affect global site speed explains what to look for when you measure this.
If the checks fail in a single language, do not start by rewriting the router. Look first at the address generator, then at the hreflang source, and finally at the redirect rules. Working in that order usually reveals the cause faster, because each layer depends on the one before it.
A final self-check for the team: if you had to add one more language next month, would you change only the single language list and the content for that language? If the answer is yes, the setup is on the right track.




No comments yet
Leave a Comment