Bilingual Portfolio Migration to Astro and Cloudflare

Resumo

Pixel shares a practical guide to moving a bilingual portfolio to Astro and Cloudflare Workers. It covers English and Russian routes, Markdown content with schema validation, canonical and alternate language links, and permanent redirects to preserve old URLs—useful insights for developers maintaining multilingual sites.

DEV Community

Moving My Bilingual Portfolio to Astro and Cloudflare Workers

Moving My Bilingual Portfolio to Astro and Cloudflare Workers My portfolio sells website development and SEO services. As I added service pages and articles, maintaining separate HTML pages and translations became repetitive. I recently moved it to Astro, keeping a static build and using a Cloudflare Worker for redirects and response headers. Here is how the project is organised and a couple of details I corrected after the migration. Routes, views, and content have separate jobs The project now has this structure: src/ pages/ # English routes and /ru routes views/ # Shared page templates layouts/ # Head metadata and page shell content/ news/en/ # English articles news/ru/ # Russian articles services/en/ # English services services/ru/ # Russian services i18n/ # Interface translations lib/ # Content helpers and structured data worker/index.js # Redirects and response headers Route files pass a language into a shared view. Article and service content lives in Markdown, with schemas validating the frontmatter during the build. That lets me change a template once while keeping editorial content separate from layout code. Render each language at its own URL English pages live at the root, and Russian pages use /ru. Both versions are generated as HTML. The shared layout builds canonical URLs and language alternates. For articles, the code checks whether a translated article with the same slug exists before linking the two versions. Most of my articles currently exist only in Russian, so this check matters. Keep old links working Changing the source structure also changed some public paths. The Worker maps old paths such as /pages/websites.html to /website with permanent redirects. Astro uses build.format: 'file', and Cloudflare serves the clean URLs. The Worker also normalises .html URLs and trailing slashes, with an exception for search-engine verification files. Keeping those verification paths intact was a detail worth checking separately from ordinary page redirects. Preserve query parameters when switching languages The site has a browser-language redirect for a first visit to an English page with a Russian equivalent. I found that it preserved the hash but dropped the query string. This preserves campaign parameters when a visitor switches to the Russian URL. The page also has an explicit language switch, and a saved language choice takes precedence over the automatic redirect. Avoid using the build date as a content update date My first sitemap implementation used the current build date for static pages and services. A deployment would therefore make unchanged pages look newly updated. I removed that fallback. Articles still use their explicit publication or update date; pages without a known content update date omit lastmod. Build and check the output Deployment runs the Astro build and uploads the static assets with Wrangler. After the latest changes, I checked that all 46 sitemap URLs had corresponding generated pages, then checked the deployed sitemap, an updated article, and the language redirect. The migration gives me a more manageable content structure. It is too early to claim a search traffic improvement: after roughly two months without organic visits, I have only recently seen the first one. My next step is to collect query and page data before deciding which content to expand. The portfolio is live at tretiakov.pro If you maintain a multilingual static site, how do you track meaningful content update dates across shared templates and individual pages?
Bilingual Portfolio Migration to Astro and Cloudflare
Powered by Readybot.io

As últimas novidades de Pixel

Incident Response: Look Beyond the Red Alert

Pixel’s DEV Community announcement explores how teams can fixate on one failing service while overlooking the real cause of an outage, such as a full …

Sach: AI Fact-Checks WhatsApp Forwards in India

Pixel’s announcement introduces Sach, a tool that checks forwarded messages in English, Hindi, Telugu, and 14 other Indian languages against official sources. It gives cited …

Java 25 Removes SecurityManager: What to Fix

Pixel’s announcement explains how Java 24’s JEP 486 permanently disabled the SecurityManager, breaking test workarounds that intercept System.exit. It recommends returning exit codes or throwing …