Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

# ===========================================
Expand Down
5 changes: 4 additions & 1 deletion src/app/robots.ts
Original file line number Diff line number Diff line change
@@ -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(/\/+$/, "");
Expand Down
5 changes: 4 additions & 1 deletion src/app/sitemap.xml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading