From e5abbf4a11782046f2aa414c2e9813f8b0d51961 Mon Sep 17 00:00:00 2001 From: MaryWylde Date: Tue, 28 Apr 2026 20:28:59 +0400 Subject: [PATCH] fix(seo): use locale-prefixed URL for JSON-LD and twitter:url MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two SEO bugs in SeoGenerator emitted URLs without the active locale prefix. Search engines indexing structured data on RU/HY pages would record the wrong canonical, leading to either a hard 404 (when slugs differ between locales — e.g. uxcore Russian transliterations) or silent locale-dilution (when slugs are the same — e.g. /ru/articles/awareness-test). Both issues stem from `router.asPath` returning the canonical (un-prefixed) path under Next.js Pages Router i18n. The existing `originalUrl` already prepends `localePath` correctly and is the source of truth used by the `` and `` tags. 1. JSON-LD `"url"`: schema generator received `pageUrl` built from `domain + router.asPath`, dropping the `/ru` or `/hy` prefix. Now reuses `originalUrl` so JSON-LD matches canonical. 2. ``: built from `https://keepsimple.io/${localePath}${alternateLink}` — a literal `/` between domain and `localePath` produced double-slash URLs (`https://keepsimple.io//ru/...` for RU, `https://keepsimple.io//...` for EN). Now also uses `originalUrl` for consistency and to eliminate the divergent-builder pattern that produced the original bug. Verified on /ru/articles/awareness-test and /ru/tools/longevity-protocol/about-project that JSON-LD `url` previously emitted the unprefixed path; rendered HTML before fix attached in the linkinator scan at reports/links-2026-04-28.json. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/SeoGenerator/SeoGenerator.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/SeoGenerator/SeoGenerator.tsx b/src/components/SeoGenerator/SeoGenerator.tsx index e882d0e..437fc7b 100644 --- a/src/components/SeoGenerator/SeoGenerator.tsx +++ b/src/components/SeoGenerator/SeoGenerator.tsx @@ -166,11 +166,10 @@ const SeoGenerator: FC = ({ const originalUrl = process.env.NEXT_PUBLIC_DOMAIN + localePath + cleanURL(alternateLink); const favIcon = `${process.env.NEXT_PUBLIC_DOMAIN}${favIconPath}`; - const pageUrl = `${process.env.NEXT_PUBLIC_DOMAIN}${router.asPath}`; const schema = generateSchema( title, stripHTML(description), - pageUrl, + originalUrl, favIcon, createdDate, modifiedDate, @@ -290,10 +289,7 @@ const SeoGenerator: FC = ({ : ogTags?.ogImage?.data?.attributes?.staticUrl } /> - +