Astro & migration guides

How We Keep Three Language Versions Linked in Astro When URLs Change

Author: Lucky Oleg | Published

On Lietuva.love, a reader looking at the Lithuanian flag can select EN and stay on the flag guide, even though both parts of its URL change. The section becomes state-symbols and the article becomes lithuanian-flag. Adding /en/ to the Lithuanian address would get both parts wrong.

We link the translations by a shared content key. Each edition supplies its own public slug. The pages, language switcher and search annotations can then look up the current addresses together. There’s one thing this lookup can’t do for a reader who saved yesterday’s address. For that, the old URL needs a redirect.

One flag guide, three live Astro URLs

On December 2, 2026, we fetched the three public flag guides from Lietuva.love, our multilingual Astro project. Each request returned HTTP 200. Open any two editions and you can compare both the path and the language of the guide.

EditionPublished pageIts section in that language
LithuanianLietuvos vėliava/valstybes-simboliai/
EnglishLithuanian flag/en/state-symbols/
RussianФлаг Литвы/ru/gosudarstvennye-simvoly/

Each page named its own address as canonical. On all three, the desktop and mobile language links led to those same three destinations. The HTML head listed lt, en, ru and x-default. The last pointed to the Lithuanian guide, so four annotations described just three pages.

The public XML sitemap gave each flag page its own entry. Each entry listed the same four alternates as the HTML. Opening the other two pages let us verify something the English page alone could never show. The Russian and Lithuanian guides both link back to it.

Give the content an identity that survives an English rename

The pairing in this collection is stateSymbols plus the translation key lietuvos-veliava. Both the English and Russian translation records refer to that key. The English record carries the slug lithuanian-flag and the Russian one carries flag-litvy. The site looks up the section name for the language separately. It can therefore change an English article slug without touching the Russian record or changing what subject either translation belongs to.

Here is the part an editor would change in the English translation record for our rename test. The key happens to match the Lithuanian slug on this site. It stays as written.

  "translationKey": "lietuvos-veliava",
- "slug": "lithuanian-flag",
+ "slug": "flag-of-lithuania",

The site’s Astro configuration sets Lithuanian as the unprefixed default language. English and Russian use prefixes. Its i18n routing helpers can construct a URL when given the locale and path. The content lookup identifies the English translation of this particular guide and supplies its current slug. For static pages, Astro’s getStaticPaths() turns the chosen paths into build output.

The deployed header shows LT, EN and RU on both desktop and mobile and gives each link an accessible label with the language name. The shorter Astro example below shows how to choose the destinations. It uses full language names for the link text and takes the same alternate records as the page head. Each record already contains the full local path, including the translated section. Changing the English slug requires no edit here.

<nav aria-label="Read this guide in another language">
  {alternates
    .filter(({ locale }) => locale !== 'x-default')
    .map(({ locale, path }) => (
      <a href={path} hreflang={locale}
         aria-current={locale === currentLocale ? 'page' : undefined}>
        {languageNames[locale]}
      </a>
    ))}
</nav>

Two safeguards matter when the collection grows. Our pairing code requires an exact key on a published base entry. It raises a build error if two base entries in the collection claim the same key, or if a translation points to a base entry it cannot find. If you’re designing this from scratch, an immutable CMS ID works too. The useful property is that changing a translated title or permalink never requires guessing which records go together.

We renamed one slug and tried the old address

We copied the site’s route and pairing helpers and the flag’s translation records into a small, separate Astro project. It rendered just this example, with a simple HTML layout and sitemap. We built it with the original spelling, changed the English slug as shown above, and built it again. The public site kept its original URLs.

What we checked in the renamed buildWhat happened
English pageIts new path was generated. Its canonical ended in /flag-of-lithuania/.
Lithuanian and Russian pagesBoth kept their own paths and canonicals. The simplified switcher on both test pages linked directly to the new English path.
All three HTML headsEach listed the new English URL, the unchanged Lithuanian and Russian URLs, and the Lithuanian fallback.
XML sitemapThe new English URL had its own entry. All three entries listed the new address as the English alternate. The old URL was absent.
Old English bookmarkThe local HTTP server returned 404 until we added a redirect. With the rule in place it returned 301, then the new English page returned 200.
In the rename test, the EN switcher links directly to flag-of-lithuania. A bookmark for lithuanian-flag reaches that same page through a 301 redirect.
Only the reader with an old bookmark needs the redirect. A reader changing languages should land on the current page in one request.

The 404 is worth pausing on. The regenerated pages and sitemap all agreed, and a reader using the language switcher would have seen no problem. Someone following a link from another site would still have lost the guide. Save the old address before publishing the new slug, then enter that old-to-new pair in the redirect configuration your host actually serves.

Check the first HTTP response as well as the final page. By default a plain static Astro build can produce an HTML file with a meta refresh, while supported adapters can write host redirect rules. Those can look alike in a browser address bar. Astro’s redirect documentation explains the difference. For a permanent move, use a server-side 301 or 308 to the final equivalent page. Google’s URL move guidance also recommends updating internal links and generally retaining redirects for at least a year.

When a translation is missing, leave its URL out

A supported language means that some of the site is available in that language. Before linking a particular guide, the build checks for a translation with a usable slug. In this collection a Russian translation becomes eligible when its status is reviewed or published. Only Russian records undergo that status check. The route builder accepts an English translation with a matching published base entry and a usable slug regardless of its review status.

For a third build we kept the English rename and marked the copied Russian record as a draft. Astro produced two pages. On each page the switcher offered LT and EN, the HTML head listed lt, en and x-default, and the sitemap listed two entries with those same alternates. There was no Russian flag page in that build. Keeping the draft on disk did not advertise it to readers.

Astro also supports language fallbacks, which can help a visitor reach content they can use. If you provide one, label the destination honestly. “Browse the Russian edition” can lead to a homepage. An RU link beside a flag guide promises the Russian flag guide. Publishing a fallback page containing Lithuanian prose under a Russian URL does not fulfill that promise.

Start with the changed guide, then open one of its unchanged translations. That second page is where a stale hardcoded switcher or alternate is easiest to miss. Four checks cover the move.

  1. Read each destination. Request each current URL directly. Check the status, page language and subject. A Russian homepage can return 200 while still being the wrong destination.
  2. Read the canonical and alternates on every page. Each of these distinct translations should name its own current canonical, include itself in the alternate set and point to the other published versions. Check that they point back. Google’s localized-page guidance describes reciprocal links and how to use x-default.
  3. Compare the sitemap if it carries alternates. Give each published URL its own <loc>. Compare each entry’s language-to-URL pairs with the HTML, including the host and trailing slash. Google accepts HTML and XML as equivalent ways to communicate alternates. We publish both from shared data and can check them against each other.
  4. Request yesterday’s URL. Verify the permanent status, its Location and the final page. If the slug has changed twice, check for a redirect chain from the oldest address. Search internal links for the old spelling too. A redirect is useful for old bookmarks, but today’s navigation should go straight to the current address.

You can use our hreflang checker to inspect a public page’s annotations and the redirect checker to follow an old address. If a canonical points to another language unexpectedly, the canonical tags guide explains what that signal asks a search engine to do.

For teams planning a multilingual Astro website build, a useful acceptance test is to hand an editor one translated slug to change. Can they publish the rename, keep the language switcher on the same subject and preserve yesterday’s bookmark? Those results are observable on the released site. Whether Google has recrawled the change or selected the new URL is a separate question for Search Console.

Recommended tools for this guide

Useful info? Spread the Aloha:

Lucky Oleg

Lucky Oleg is the founder of Web Aloha, a web design & SEO agency helping businesses ride the digital wave. With years of experience in WordPress, technical SEO, and web performance, he writes about what actually works in the real world.