Add page metadata across every route

The root layout exported no metadata, so routes without their own export
rendered no title at all, and no route had a description. Add a root
metadata block with a title template, Open Graph and Twitter defaults,
and fill in the routes that were missing tags.

- config/site.ts: description and env-driven absolute url for metadataBase
- home, /collections and /shop/collections: titles and descriptions
- products/[handle] and collections/[handle]: generateMetadata off the
  existing catalog fetchers, with canonical and OG image
- existing titles: drop the hand-written " — Shop" suffix now that the
  root template appends it

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011x5jT4fJJCnqPx3umEvXRk
This commit is contained in:
Rami Bitar
2026-08-09 09:35:57 -04:00
co-authored by Claude Opus 5
parent a230187e9f
commit 0263a59c6a
15 changed files with 160 additions and 8 deletions
+6 -1
View File
@@ -1,5 +1,6 @@
import { notFound } from 'next/navigation';
import { getShopPolicy, POLICY_HANDLES } from '@/hooks/use-shopify-policies';
import { site } from '@/config/site';
export function generateStaticParams() {
return POLICY_HANDLES.map((handle) => ({ handle }));
@@ -13,8 +14,12 @@ export async function generateMetadata({
const { handle } = await params;
const policy = await getShopPolicy(handle);
if (!policy) return { title: 'Policy' };
return {
title: policy ? `${policy.title} — Shop` : 'Policy — Shop',
title: policy.title,
description: `Read the ${policy.title.toLowerCase()} for ${site.storeName}.`,
alternates: { canonical: `/policies/${policy.handle}` },
};
}