From 1cf950c178a644786f90b2fafd06884ccda97ac8 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Sun, 5 Jul 2026 00:38:57 -0500 Subject: [PATCH 1/6] fix: serve homepage at root instead of meta-refresh redirect to /en/ --- src/pages/[lang]/index.astro | 5 +++-- src/pages/index.astro | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 src/pages/index.astro diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index 33f53f4281..66d43951e3 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -6,16 +6,17 @@ import { languageCodes } from '@i18n/locales'; import { getLangFromUrl, useTranslations } from '@i18n/utils'; export function getStaticPaths() { - return languageCodes.map((lang) => ({ + return ['/', ...languageCodes].map((lang) => ({ params: { lang }, })); } const lang = getLangFromUrl(Astro.url); const t = useTranslations(lang); +const canonicalPathname = lang === 'en' ? '/' : `/${lang}/`; --- - + diff --git a/src/pages/index.astro b/src/pages/index.astro deleted file mode 100644 index 655eb6cb65..0000000000 --- a/src/pages/index.astro +++ /dev/null @@ -1 +0,0 @@ - From 3f8976308617f70167832760e67d7e58590d56f5 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Sun, 5 Jul 2026 00:49:42 -0500 Subject: [PATCH 2/6] fixup! --- src/components/HomePage.astro | 29 +++++++++++++++++++++++++++++ src/pages/[lang]/index.astro | 30 +++--------------------------- src/pages/index.astro | 5 +++++ 3 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 src/components/HomePage.astro create mode 100644 src/pages/index.astro diff --git a/src/components/HomePage.astro b/src/components/HomePage.astro new file mode 100644 index 0000000000..51b924e5df --- /dev/null +++ b/src/components/HomePage.astro @@ -0,0 +1,29 @@ +--- +import { Hero, Features, AnnouncementBar } from '@components/patterns'; +import { Card, Col } from '@components/primitives'; +import Layout from '@layouts/Layout.astro'; +import { getLangFromUrl, useTranslations } from '@i18n/utils'; + +const lang = getLangFromUrl(Astro.url); +const t = useTranslations(lang); +const canonicalPathname = lang === 'en' ? '/' : `/${lang}/`; +--- + + + + + + + + + + + + + + + + + + + diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index 66d43951e3..b71d18b70c 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -1,36 +1,12 @@ --- -import { Hero, Features, AnnouncementBar } from '@components/patterns'; -import { Card, Col } from '@components/primitives'; -import Layout from '@layouts/Layout.astro'; +import HomePage from '@components/HomePage.astro'; import { languageCodes } from '@i18n/locales'; -import { getLangFromUrl, useTranslations } from '@i18n/utils'; export function getStaticPaths() { - return ['/', ...languageCodes].map((lang) => ({ + return languageCodes.map((lang) => ({ params: { lang }, })); } - -const lang = getLangFromUrl(Astro.url); -const t = useTranslations(lang); -const canonicalPathname = lang === 'en' ? '/' : `/${lang}/`; --- - - - - - - - - - - - - - - - - - - + diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000000..1cc2ede7a1 --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,5 @@ +--- +import HomePage from '@components/HomePage.astro'; +--- + + From 92ad7010d4da47879e818448b5c7761587303937 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Sun, 5 Jul 2026 01:02:18 -0500 Subject: [PATCH 3/6] fixup! --- src/components/patterns/Header/Header.astro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/patterns/Header/Header.astro b/src/components/patterns/Header/Header.astro index b4983efc83..1585a1d22d 100644 --- a/src/components/patterns/Header/Header.astro +++ b/src/components/patterns/Header/Header.astro @@ -14,6 +14,7 @@ import { getLangFromUrl, useTranslations } from '@/i18n/utils'; const currentLang = getLangFromUrl(Astro.url); const t = useTranslations(currentLang); +const homeHref = currentLang === 'en' ? '/' : `/${currentLang}/`; ---
@@ -30,7 +31,7 @@ const t = useTranslations(currentLang); - + Express.js kawaii logo Date: Sun, 5 Jul 2026 01:07:39 -0500 Subject: [PATCH 4/6] fix(seo): update sitemap and alternate links for homepage canonical URLs --- astro.config.mjs | 6 ++++-- src/layouts/Layout.astro | 20 ++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index bc6458a1c3..19fbcb5832 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -73,13 +73,15 @@ export default defineConfig({ icon(), react(), sitemap({ - // Only the canonical //… URLs belong in the sitemap. The catch-all + // Only the canonical URLs belong in the sitemap. The catch-all // `[...path].astro` also emits `noindex` redirect stubs: language-less ones - // (e.g. `/guide/x`, `/` → `/en/`) and per-locale ones for moved pages + // (e.g. `/guide/x`) and per-locale ones for moved pages // (e.g. `/en/resources/middleware/csurf`). Exclude both. // Keep this locale list in sync with `i18n.locales` below. filter: (page) => { const { pathname } = new URL(page); + // The homepage is served at `/` and is the canonical for `/en/`. + if (pathname === '/') return true; if (!/^\/(de|en|es|fr|it|ja|ko|pt-br|zh-cn|zh-tw)(\/|$)/.test(pathname)) return false; const unlocalized = pathname.replace(/^\/[a-z-]+/, '').replace(/\/$/, ''); return !movedPagePaths.has(unlocalized); diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index b406a93228..d0369930e0 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -100,18 +100,14 @@ const lang = getLangFromUrl(Astro.url); { !isBlogOrApi && - ['x-default', ...languageCodes].map((altLang) => ( - - )) + ['x-default', ...languageCodes].map((altLang) => { + let altPath = replaceLanguageInPath(canonicalPath, altLang === 'x-default' ? 'en' : altLang); + // The English homepage is canonically served at `/`, not `/en/`. + if (altPath === '/en/') altPath = '/'; + return ( + + ); + }) } {pageTitle} From bdedd49b0ecd136b3ca4a9a0d03306849c599bc9 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Sun, 5 Jul 2026 14:17:33 -0500 Subject: [PATCH 5/6] fix(i18n): implement getHomePath function for canonical homepage URLs --- src/components/HomePage.astro | 4 ++-- src/components/patterns/Breadcrumbs/Breadcrumbs.astro | 5 +++-- src/components/patterns/Header/Header.astro | 4 ++-- .../patterns/LanguageSelect/LanguageSelect.astro | 3 ++- src/components/patterns/Sidebar/SidebarMenu.astro | 4 ++-- src/i18n/utils.ts | 7 +++++++ src/pages/[...path].astro | 2 ++ 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/components/HomePage.astro b/src/components/HomePage.astro index 51b924e5df..3588a2f2a4 100644 --- a/src/components/HomePage.astro +++ b/src/components/HomePage.astro @@ -2,11 +2,11 @@ import { Hero, Features, AnnouncementBar } from '@components/patterns'; import { Card, Col } from '@components/primitives'; import Layout from '@layouts/Layout.astro'; -import { getLangFromUrl, useTranslations } from '@i18n/utils'; +import { getHomePath, getLangFromUrl, useTranslations } from '@i18n/utils'; const lang = getLangFromUrl(Astro.url); const t = useTranslations(lang); -const canonicalPathname = lang === 'en' ? '/' : `/${lang}/`; +const canonicalPathname = getHomePath(lang); --- diff --git a/src/components/patterns/Breadcrumbs/Breadcrumbs.astro b/src/components/patterns/Breadcrumbs/Breadcrumbs.astro index 49830532d7..a591f0fe3d 100644 --- a/src/components/patterns/Breadcrumbs/Breadcrumbs.astro +++ b/src/components/patterns/Breadcrumbs/Breadcrumbs.astro @@ -6,7 +6,7 @@ import { Body } from '@components/primitives'; import { Icon } from 'astro-icon/components'; import type { BreadcrumbItem } from '@utils/content'; -import { getLangFromUrl, useTranslations } from '@/i18n/utils'; +import { getHomePath, getLangFromUrl, useTranslations } from '@/i18n/utils'; import './Breadcrumbs.css'; interface Props { @@ -16,6 +16,7 @@ interface Props { const { items } = Astro.props; const lang = getLangFromUrl(Astro.url); const t = useTranslations(lang); +const homeHref = getHomePath(lang); ---