diff --git a/env.example b/env.example index 4eaaa1b..abe7fc9 100644 --- a/env.example +++ b/env.example @@ -3,7 +3,7 @@ # =========================================== # Site Configuration -NEXT_PUBLIC_SITE_URL=https://gnars.com +NEXT_PUBLIC_SITE_URL=https://www.gnars.com NEXT_PUBLIC_BASE_URL=http://localhost:3000 # =========================================== diff --git a/src/app/robots.ts b/src/app/robots.ts index 74a109d..2cec847 100644 --- a/src/app/robots.ts +++ b/src/app/robots.ts @@ -1,6 +1,9 @@ import type { MetadataRoute } from "next"; -const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://gnars.com"; +// Canonical host is www.gnars.com (matches metadataBase in [locale]/layout.tsx +// and BASE_URL in lib/config.ts). Keeping this in sync is what lets Google index +// the site — a non-www default here made every sitemap URL a redirect to www. +const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://www.gnars.com"; export default function robots(): MetadataRoute.Robots { const normalized = SITE_URL.replace(/\/+$/, ""); diff --git a/src/app/sitemap.xml/route.ts b/src/app/sitemap.xml/route.ts index 5547735..f74bc1f 100644 --- a/src/app/sitemap.xml/route.ts +++ b/src/app/sitemap.xml/route.ts @@ -30,7 +30,10 @@ const PROPOSAL_PAGE_SIZE = 200; const MAX_COIN_PAGES = 50; const COIN_PAGE_SIZE = 200; -const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://gnars.com"; +// Canonical host is www.gnars.com (matches metadataBase in [locale]/layout.tsx +// and BASE_URL in lib/config.ts). A non-www default here emitted 2,564 URLs that +// all 307-redirected to www, so Google dropped them — keep this on www. +const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://www.gnars.com"; const BASE = SITE_URL.replace(/\/+$/, ""); const toUrl = (path: string) => new URL(path, `${BASE}/`).toString();