Astro Static Site with Full SEO Support for 10 Locales
Astro is a fantastic choice for content-heavy static sites: it ships zero JavaScript by default, supports any UI framework, and generates pure HTML that search engines love. Adding 10 locales on top might sound like a headache — but with the right tooling, it's a one-command workflow. This guide shows how to localize an Astro site with SiteLocaleAI and keep full SEO support for every locale.
Why Astro + LLM Translation Works
Astro's static output means every page is pre-rendered at build time. That's great for SEO, but it also means translated content must exist in the build, not fetched at runtime. SiteLocaleAI's CLI handles this: it translates your content with your own LLM API keys, then pre-renders fully localized pages that search engines can crawl and index.
Because SiteLocaleAI is a drop-in JS library and framework agnostic, it slots into Astro without fighting the framework's routing or build pipeline.
Step 1: Install and Configure
Install the library and CLI:
npm install sitelocaleai
npm install -D @sitelocaleai/cli
Create sitelocale.config.js at the project root:
module.exports = {
locales: ['en', 'es', 'fr', 'de', 'it', 'pt', 'ja', 'ko', 'zh', 'ar'],
defaultLocale: 'en',
provider: 'openai',
model: 'gpt-4o-mini',
apiKey: process.env.OPENAI_API_KEY,
priceLocalization: true,
seo: {
preRender: true,
hreflang: true,
},
};
Your API keys stay in your environment — SiteLocaleAI is self-hosted, so you control the LLM provider and costs.
Step 2: Set Up Astro's i18n Routing
Astro has built-in i18n routing. Configure astro.config.mjs to match your locale list:
import { defineConfig } from 'astro/config';
export default defineConfig({
i18n: {
defaultLocale: 'en',
locales: ['en', 'es', 'fr', 'de', 'it', 'pt', 'ja', 'ko', 'zh', 'ar'],
routing: {
prefixDefaultLocale: false,
},
},
});
This gives you clean URLs like /es/blog/, /fr/pricing/, and so on, with the default locale served at the root.
Step 3: Translate Content at Build Time
SiteLocaleAI translates your content using the LLM of your choice. In an Astro content collection, run translation as part of your build step:
npx sitelocale translate --source ./src/content --out ./src/content
The CLI reads your Markdown and JSON content, translates each entry into all configured locales, and writes locale-specific files. Astro then builds them into static pages. Check the translation workflow docs for details on content collections and frontmatter handling.
Step 4: Localize Prices with Psychological Rounding
If you sell products or list plans, hardcoded prices look wrong in other currencies. SiteLocaleAI localizes prices and applies psychological rounding per currency — so $49 might become €49 or ¥4,980 depending on what converts and reads naturally.
---
import { localizePrice } from 'sitelocaleai';
const price = localizePrice(49, 'USD', Astro.currentLocale);
---
<p class="price">{price}</p>
This happens at build time, so the static HTML contains the correct price for each locale — no client-side flicker, no SEO penalty.
Step 5: Add hreflang and Canonical Tags
For 10 locales, correct hreflang setup is non-negotiable. Add this to your base layout:
---
import { getHreflangTags } from 'sitelocaleai';
const hreflang = getHreflangTags(Astro.url.pathname, Astro.currentLocale);
---
<head>
{hreflang.map(({ hreflang, href }) => (
<link rel="alternate" hreflang={hreflang} href={href} />
))}
<link rel="canonical" href={hreflang.find(l => l.hreflang === 'x-default').href} />
</head>
SiteLocaleAI generates the full set of reciprocal hreflang tags, including x-default, so Google understands the relationship between all 10 versions.
Step 6: Pre-Render for Search Engines
The CLI's SEO pre-rendering step ensures search engines get fully translated, indexed pages rather than client-side-translated content:
npx sitelocale seo:prerender --dist ./dist
Run this after astro build. It post-processes the static output, injecting translated meta tags, localized structured data, and sitemap entries per locale. Search engines see complete, crawlable HTML for every locale.
Step 7: Generate a Multilingual Sitemap
Add a sitemap step to your build:
npx sitelocale sitemap --dist ./dist --locales es,fr,de,it,pt,ja,ko,zh,ar
This produces locale-indexed sitemap files with xhtml:link alternates, so Google can discover every translated URL quickly.
Putting It All Together
Your package.json build script becomes:
"scripts": {
"build": "astro build && sitelocale seo:prerender --dist ./dist && sitelocale sitemap --dist ./dist"
}
One build, ten locales, full SEO coverage — hreflang, canonicals, localized prices, and pre-rendered pages.
Wrapping Up
Localizing an Astro site into 10 locales doesn't require a separate CMS or a team of translators. With SiteLocaleAI's drop-in library, CLI, and price localization, your static Astro build produces SEO-complete pages for every market. Review the framework integration docs for Astro-specific configuration and advanced hreflang options.
Ready to go global? Start with the $5 Indie plan, point SiteLocaleAI at your Astro project, and ship your first multilingual build today. Try SiteLocaleAI and watch your international SEO compound.