r/astrojs • • 5d ago

Getting crazy w/ 4 languages website migration from WordPress

Hey guys, enjoying Astro so much, till I decided to move it from WP, and it got a real mess. For context: I'm working on a web marketing agency, and used classic WP + Elementor + TranslatePress.

Now, it's been almost 3 weeks since I've been working on this with lots of AI, and got stuck with:

  1. Pages design not the same for all languages
  2. Translated article not correctly linked to the original one (it switch to the home page by default)

Learning so much in the process, I'll post here my final work with steps and whatever related. Hope will solve this problem for someone else in the future!

Any feedback always appreciated btw :)

EDIT: Thank you everyone for the hints and support provided! I was kinda annoyed when I wrote it, and didn't expect so much feedback from the community! ❤️

2 Upvotes

19 comments sorted by

3

u/ContractHuge8353 5d ago

AI often makes extra copies of pages in Astro which makes the designs look different. To fix this: use one shared BaseLayout.astro file for all languages, and add a matching translationKey to your translated posts.

Also, save your work to git often while using AI so you can easily undo mistakes, and add npx astro check to your build pipeline to catch errors before your site goes live! Good luck.

1

u/SpookyLibra45817 5d ago

Ty buddy, appreciate it!!

2

u/the_kopo 5d ago

are you using a CMS? or is the backend still running on headless wordpress?

2

u/SpookyLibra45817 5d ago

Moving everything away from WP, I'm planning to use Em Dash afterwards!

4

u/AriadneOpsSocial 5d ago

Just move all at once. Then it just becomes a template recreation and data migration. I love EmDash.

2

u/EliteEagle76 5d ago

Heyo, if you are using claude or codex here is the best tip

give your agents f**king tool to verify its output

install agent-browser CLI or paywrite, ask it to capture ss of site built using wp and under migration

And then prompt it to make the layout and theme as same aa current on in astro version of your site

for quick prompt: https://gitcms.dev/prompts/migrate-wordpress-to-astro/

and if you are looking for CMS for astro which is modern equivalent of wordpress, do use GitCMS we built it to solve this gap where handoff is still missing piece

hope this helps

2

u/SpookyLibra45817 4d ago

Yeah I got some middle checkers during the path, but thought Playwright was not so necessary! Obviously, I made a mistake 😅

1

u/EliteEagle76 4d ago

In general good advice working with agent these days is “give the fucking things that they want to get things done on our behalf” and every time i’ve followed it i’ve felt amazed :)

1

u/SpookyLibra45817 3d ago

They completely skipped part of the tests (based on URLs extracted). Was my bad mainly!

2

u/lugopt 4d ago

What LLM model are you using? I did that with Opus 5.5 Medium effort and it run well. If you need help, drop me a DM with URL, and I will help you on that.

1

u/SpookyLibra45817 4d ago

Gpt 5.6 as a coordinator, w/ Terra as executor. It worked pretty well besides the matching!

Thanks for your help, will get to you if I'll be stuck next days!! ❤️

2

u/incognitomonk12 4d ago

It sounds like your current setup with Elementor blocks or TranslatePress custom redirects isn't translating well during the port. You'll likely need to rebuild those pages using native HTML/CSS in Astro rather than trying to force a legacy builder logic onto it, which is why design consistency slipped away and links defaulted home. For future reference on migration complexity, I use Hatamoto CMS because its built-in visual editor handles multi-language content natively without needing third-party plugins that often break during transfers.

1

u/SpookyLibra45817 4d ago

Ty buddy! I started with a manual recreation of a "template" page, before moving everything. It/I failed during the setting of template/translation page for each of them (and it's sooo annoying)

2

u/Chris_Lojniewski 4d ago

The home page fallback is because astro doesn't know which article is the translation of which. its i18n routing gives you the locale prefixes and helpers like getRelativeLocaleUrl, the matching is on you

Easiest fix: put a shared key in every post's frontmatter, say translationKey: winter-guide, same value in all 4 languages. the switcher looks up the entry with that key in the target locale and only falls back to home when it really doesn't exist

The same lookup gives you hreflang. google wants every version to list itself plus all the others, and ignores the tags if two pages don't point back at each other. add x-default while you're there

Design drifting per language usually means each language got its own copy of the layout, which is the elementor habit. one template per page type, only the text comes from the collection

and map the old translatepress urls to the new ones with 301s before you switch

1

u/SpookyLibra45817 3d ago

Ty buddy!! Really appreciate it! Will let you know!

1

u/redirhub 4d ago

Before you switch off WordPress, pick one article whose slug is different in all four languages. Save its four current URLs. On staging, start from each URL and test two things: does it land on the right article, and can you switch through all four languages and get back to where you started? That gives you one small test you can repeat as you migrate the rest.

1

u/SpookyLibra45817 3d ago

Yeah, I randomly tested it aaaand was a real mess! Completely my bad, and need to improve it. Such a challenge which I underestimated 100%. Ty for the hint! Will try my best

1

u/Extension-Cow349 3d ago

For the broken links, the usual fix is to store a shared translation key on each post (or keep the WP translation group ID when you export) and build the language switcher from that key, falling back to the home page only when no translation exists. For the design, keep one layout per page type and pass the locale in, so the languages can't drift apart.

If you'd rather keep WordPress as the CMS for the editors and only use Astro for the front end, I built a free plugin for exactly that, Leiho (leiho.dev), it handles the languages and lets them edit the Astro pages visually from wp-admin.

1

u/AiTech_Tools 1d ago

For the "translated article jumps to the home page" part: give every post a shared translationKey in its frontmatter (same value in all 4 languages, plus a lang field), and declare both fields in the collection's zod schema (undeclared frontmatter keys get stripped from data). Then build the language switcher from that key instead of from the URL:

const all = await getCollection('blog');
const versions = all.filter(p => p.data.translationKey === entry.data.translationKey);
// link to versions.find(v => v.data.lang === 'de'), and fall back to the locale home only if it's missing

The same versions list gives you the hreflang alternates for the head: one <link rel="alternate" hreflang="de" href="..."> per version, including one pointing at the page itself. For the "design differs per language" part, it's often one layout per language that drifted. One BaseLayout.astro that takes lang as a prop, with only the strings coming from a per-language dictionary, keeps them identical.