Back to blog

Keeping translated URLs when an article isn't translated

How this site separates a working language switcher from search indexing for untranslated posts.


A language switcher can preserve the article a reader is viewing even when that article has no translation. The destination still needs to say what it actually contains. On this site, the publication policy makes that distinction explicitly:

const translated = originalPublished && translationExists && !translationDraft;
const articleLang = translated ? routeLang : 'en';
const indexable = originalPublished && translated;

This is a simplified version of the decision in publication.mjs. It assumes the route is a non-English locale; the English original is its own translation. A draft original is never published, even if a translation file exists.


A working route and an honest document

For a published English post without a Serbian translation, /sr/blog/example/ remains a valid destination. The document language is Serbian because the navigation is Serbian; the article itself has lang="en". The page points its canonical link to the English URL and carries noindex. It does not advertise the fallback as a Serbian hreflang alternative or include it in the sitemap.

When a real Serbian translation is published, the same route serves that translation, becomes indexable, and joins the alternatives. This keeps links stable as translations arrive. Google documents localized alternatives and explains that noindex requires a crawlable page. These are signals to search engines, not guarantees about which URL will appear in results.

The trade-off

A fallback is useful for navigation, but it is not localized content. A reader who expects Serbian may still find an English article. The lang attribute helps assistive technology select the right pronunciation; it does not translate the text. The better long-term fix is a complete translation, not a metadata change.

Canonical URLs serve a different purpose from language alternatives. Google’s canonicalization documentation describes how duplicate URLs are consolidated; hreflang describes language variants. Keeping those decisions in one publication module makes it easier for the page, feed, and sitemap to agree.