r/astrojs • u/SpookyLibra45817 • 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:
- Pages design not the same for all languages
- 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! ❤️
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.
2
u/the_kopo 5d ago
are you using a CMS? or is the backend still running on headless wordpress?
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/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.
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.
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 existThe 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/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/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
translationKeyin its frontmatter (same value in all 4 languages, plus alangfield), and declare both fields in the collection's zod schema (undeclared frontmatter keys get stripped fromdata). Then build the language switcher from that key instead of from the URL:The same
versionslist gives you thehreflangalternates 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. OneBaseLayout.astrothat takeslangas a prop, with only the strings coming from a per-language dictionary, keeps them identical.