Blazor localization
Build SEO-friendly culture URLs in Blazor
Use /en-us/page-name/ routes for direct access.
The goal is a stable URL system, not just translated text.
Why it matters
Culture URLs help people and crawlers choose the right page
A cookie can change language after a request.
A URL can be shared, crawled, indexed, cached, and audited.
Culture routes fit public articles, product pages, docs, and tools.
Table of Content
Core concepts
Separate language, region, route, and content version
Keep these terms separate before you write routing code.
Use language for readable text.
English, German, and French are language choices.
Use region for local intent.
en-us and en-gb can need different spelling, examples, and offers.
Use routes for discovery.
A route like /de-de/blazor/ gives everyone one stable address.
Use content when intent differs.
Write a separate version when legal notes, prices, or examples differ.
SEO signals
Connect culture routes with canonical and hreflang rules
The URL is only one signal. Metadata must match it.
Canonical URL
Point each localized page at its own preferred URL.
hreflang
Link every real language or region version with hreflang.
x-default
Use x-default for a neutral selector or global fallback.
BreadcrumbList
Keep breadcrumbs culture-aware so schema matches the visible route hierarchy.
Related reference
Metadata and schema must tell the same story
Use these guides when you add metadata and structured data.
Implementation
Build the route rules in small pieces
Start with one service, one redirect, and one route pattern.
Culture service contract
Centralize supported cultures and URL parsing.
public sealed class CultureRouteService
{
private static readonly string[] SupportedCultures = ["en-us", "en-gb", "de-de"];
public string ResolveCulture(string? routeCulture)
{
if (SupportedCultures.Contains(routeCulture, StringComparer.OrdinalIgnoreCase))
{
return routeCulture!.ToLowerInvariant();
}
return "en-us";
}
}Culture redirect endpoint
Set the cookie, then return to the culture route.
[Route("culture")]
public sealed class CultureController : Controller
{
[HttpGet("set")]
public IActionResult Set(string culture, string returnUrl)
{
Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)));
return LocalRedirect(returnUrl);
}
}Program setup
Register localization before you map controller routes.
builder.Services.AddLocalization();
builder.Services.AddScoped<CultureRouteService>();
app.UseRequestLocalization(options =>
{
options.SetDefaultCulture("en-us");
options.AddSupportedCultures("en-us", "en-gb", "de-de");
options.AddSupportedUICultures("en-us", "en-gb", "de-de");
});
app.MapControllers();Page route
Make the culture segment part of every public route.
@page "/{Culture}/pricing/"
<a href="@BuildCultureLink(PageLinks.Blazor)">
Blazor guides
</a>Route reality
Blazor can localize content, not route templates
The culture segment changes; the slug stays stable. Translated slugs need their own routing layer.
Razor @page routes use literal templates. Localization translates page text only. PageLinks and @page strings stay code-owned.
/de-de/seo-friendly-culture-links-in-blazor/
Only the culture changes.
/de-de/seo-freundliche-culture-links-in-blazor/
Translated slugs need a slug table. They also need redirects, canonicals, sitemaps, and hreflang.
BuildCultureLink(PageLinks.Blazor)
BuildCultureLink changes culture, not slugs.
Common mistakes
Most culture URL bugs are routing mismatches
The route template is rarely the hard part.
Keep every signal aligned after a language change.
Do not redirect a valid culture forever.
Normalize the culture once, then stop when the route already matches.
Do not guess the default culture late.
Use one default culture for routing, metadata, sitemap, and fallback logic.
Do not let two pages own the same culture slug.
Central page links make accidental route collisions easier to review.
Do not hide language routes in client-only state.
Crawlers and users need real href values before Blazor becomes interactive.
Validation
Check each culture route before publishing
Validate rendered HTML, not only Razor code.
- Open at least one URL for each supported culture.
- Check canonical and hreflang tags in the rendered source.
- Confirm FAQ schema matches the visible questions and answers.
- Crawl redirects so unsupported cultures do not loop.
- Review translated titles, descriptions, H1 text, and keywords.
FAQ
Are culture URLs better than cookies for SEO?
Yes. Culture URLs create crawlable and shareable pages.
What is the difference between language and region?
Language controls text. Region controls local examples and offers.
Do I still need hreflang with culture routes?
Yes. Culture routes make URLs clear. hreflang connects them.
What should canonical point to on localized pages?
Usually, canonical points to the same localized page.
How do I avoid redirect loops?
Redirect unsupported cultures once, then stop.