From 01959cdf2236fd179afe796be0e74ed5d31e2441 Mon Sep 17 00:00:00 2001 From: Bailey Pumfleet Date: Mon, 23 Nov 2026 12:47:09 -0600 Subject: [PATCH 1/2] fix(seo): self-referencing canonical URLs on /ui and /origin Every indexable page now emits one absolute canonical on coss.com, matching what its sitemap lists (basePath included, no trailing slash). Filtered views (?tags=) canonicalize to the unfiltered page, and the raw Markdown copies of docs pages (/ui/docs/.md) send a canonical Link header pointing at the HTML page. The sitemaps build their URLs from the same helper so the two can't drift. Origin's banner links to coss.com/ui instead of coss.com/ui/, which redirected. --- apps/origin/app/[category]/page.tsx | 4 ++++ apps/origin/app/easings/page.tsx | 2 ++ apps/origin/app/page.tsx | 6 ++++++ apps/origin/app/search/page.tsx | 3 +++ apps/origin/app/sitemap.ts | 9 +++++---- apps/origin/components/top-banner.tsx | 3 ++- apps/origin/lib/canonical.ts | 12 ++++++++++++ apps/ui/app/api/raw/[...slug]/route.ts | 18 ++++++++++++------ apps/ui/app/chat/page.tsx | 2 ++ apps/ui/app/docs/[[...slug]]/page.tsx | 2 ++ apps/ui/app/page.tsx | 2 ++ apps/ui/app/particles/page.tsx | 3 +++ apps/ui/app/sitemap.ts | 9 +++++---- apps/ui/lib/canonical.ts | 11 +++++++++++ 14 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 apps/origin/lib/canonical.ts create mode 100644 apps/ui/lib/canonical.ts diff --git a/apps/origin/app/[category]/page.tsx b/apps/origin/app/[category]/page.tsx index 6494191d85..c6deb3ff1f 100644 --- a/apps/origin/app/[category]/page.tsx +++ b/apps/origin/app/[category]/page.tsx @@ -7,6 +7,7 @@ import Cta from "@/components/cta"; import PageGrid from "@/components/page-grid"; import PageHeader from "@/components/page-header"; import { categories, getCategory } from "@/config/components"; +import { absoluteUrl } from "@/lib/canonical"; import { getComponentsByNames } from "@/lib/utils"; type Props = { @@ -26,10 +27,12 @@ export async function generateMetadata({ params }: Props): Promise { ); const isSingleComponent = components.length === 1; + const alternates = { canonical: absoluteUrl(`/${category.slug}`) }; // Custom title and description for event-calendar if (category.slug === "event-calendar") { return { + alternates, description: "An event calendar component built with React and Tailwind CSS. Originally built in v0 and currently in early alpha stage.", title: @@ -38,6 +41,7 @@ export async function generateMetadata({ params }: Props): Promise { } return { + alternates, description: isSingleComponent ? `A beautiful and accessible ${category.name.toLowerCase()} component built with React and Tailwind CSS.` : `A collection of beautiful and accessible ${category.name.toLowerCase()} components built with React and Tailwind CSS.`, diff --git a/apps/origin/app/easings/page.tsx b/apps/origin/app/easings/page.tsx index b9bde72d52..206515f3e2 100644 --- a/apps/origin/app/easings/page.tsx +++ b/apps/origin/app/easings/page.tsx @@ -1,8 +1,10 @@ import type { Metadata } from "next"; import Easings from "./easings"; import PageHeader from "@/components/page-header"; +import { absoluteUrl } from "@/lib/canonical"; export const metadata: Metadata = { + alternates: { canonical: absoluteUrl("/easings") }, description: "A collection of easing utility classes to enhance your Tailwind CSS animations and transitions.", title: "Tailwind CSS Easing Classes - coss.com origin", diff --git a/apps/origin/app/page.tsx b/apps/origin/app/page.tsx index 159d1b8ec1..bb2aa6ea2b 100644 --- a/apps/origin/app/page.tsx +++ b/apps/origin/app/page.tsx @@ -1,8 +1,14 @@ +import type { Metadata } from "next"; import Image from "next/image"; import Link from "next/link"; import SearchButton from "@/components/search-button"; import { SubscribeBottom } from "@/components/subscribe-form"; import { categories } from "@/config/components"; +import { absoluteUrl } from "@/lib/canonical"; + +export const metadata: Metadata = { + alternates: { canonical: absoluteUrl("/") }, +}; export default function Page() { return ( diff --git a/apps/origin/app/search/page.tsx b/apps/origin/app/search/page.tsx index 832fbe3de0..e9cebe024f 100644 --- a/apps/origin/app/search/page.tsx +++ b/apps/origin/app/search/page.tsx @@ -2,8 +2,11 @@ import type { Metadata } from "next"; import { Suspense } from "react"; import ComponentsContainer from "./components-container"; import PageHeader from "@/components/page-header"; +import { absoluteUrl } from "@/lib/canonical"; export const metadata: Metadata = { + // Filtered views (?tags=…) are the same page. + alternates: { canonical: absoluteUrl("/search") }, description: "Search for components in the UI library.", title: "Search a UI component", }; diff --git a/apps/origin/app/sitemap.ts b/apps/origin/app/sitemap.ts index 2a477163f4..d2b6a29990 100644 --- a/apps/origin/app/sitemap.ts +++ b/apps/origin/app/sitemap.ts @@ -1,18 +1,19 @@ import type { MetadataRoute } from "next"; import { categories } from "@/config/components"; +import { absoluteUrl } from "@/lib/canonical"; export default function sitemap(): MetadataRoute.Sitemap { const home = { - url: "https://coss.com/origin", + url: absoluteUrl("/"), }; const search = { - url: "https://coss.com/origin/search", + url: absoluteUrl("/search"), }; const easings = { - url: "https://coss.com/origin/easings", + url: absoluteUrl("/easings"), }; const categoryPages = categories.map((category) => ({ - url: `https://coss.com/origin/${category.slug}`, + url: absoluteUrl(`/${category.slug}`), })); return [home, ...categoryPages, search, easings]; diff --git a/apps/origin/components/top-banner.tsx b/apps/origin/components/top-banner.tsx index 340d61ae35..e5a48a7a82 100644 --- a/apps/origin/components/top-banner.tsx +++ b/apps/origin/components/top-banner.tsx @@ -2,7 +2,8 @@ import { ArrowUpRightIcon } from "lucide-react"; export default function TopBanner() { const gatewayOrigin = process.env.NEXT_PUBLIC_COSS_UI_URL || ""; - const gatewayHome = gatewayOrigin ? `${gatewayOrigin}/` : "/"; + // No trailing slash: coss.com/ui/ redirects to coss.com/ui, the canonical. + const gatewayHome = gatewayOrigin ? gatewayOrigin.replace(/\/$/, "") : "/"; return (
diff --git a/apps/origin/lib/canonical.ts b/apps/origin/lib/canonical.ts new file mode 100644 index 0000000000..e90275df92 --- /dev/null +++ b/apps/origin/lib/canonical.ts @@ -0,0 +1,12 @@ +/** Where this app is served in production (its basePath on coss.com). */ +export const SITE_URL = "https://coss.com/origin"; + +/** + * A page's absolute URL on coss.com, exactly as the sitemap lists it: the + * basePath included, no trailing slash. Pages use it as their canonical, so + * copies of a page (query strings, preview deployments) all point search + * engines at one URL. + */ +export function absoluteUrl(path = "/"): string { + return path === "/" ? SITE_URL : `${SITE_URL}${path}`; +} diff --git a/apps/ui/app/api/raw/[...slug]/route.ts b/apps/ui/app/api/raw/[...slug]/route.ts index b2eb6fbaf7..379e6c35cf 100644 --- a/apps/ui/app/api/raw/[...slug]/route.ts +++ b/apps/ui/app/api/raw/[...slug]/route.ts @@ -1,6 +1,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import { type NextRequest, NextResponse } from "next/server"; +import { absoluteUrl } from "@/lib/canonical"; export async function GET( _request: NextRequest, @@ -37,13 +38,18 @@ export async function GET( content = await fs.readFile(mdPath, "utf-8"); } + const headers: Record = { + "Cache-Control": "public, max-age=3600", + "Content-Type": "text/plain; charset=utf-8", + }; + // `/docs/.md` is a copy of the docs page: point search engines at it. + if (slug[0] === "docs") { + const page = `/${slug.join("/")}`.replace(/\.mdx?$/, ""); + headers.Link = `<${absoluteUrl(page)}>; rel="canonical"`; + } + // Return raw markdown with appropriate headers - return new NextResponse(content, { - headers: { - "Cache-Control": "public, max-age=3600", - "Content-Type": "text/plain; charset=utf-8", - }, - }); + return new NextResponse(content, { headers }); } catch { return NextResponse.json({ error: "File not found" }, { status: 404 }); } diff --git a/apps/ui/app/chat/page.tsx b/apps/ui/app/chat/page.tsx index defc476f60..f4aa01dac5 100644 --- a/apps/ui/app/chat/page.tsx +++ b/apps/ui/app/chat/page.tsx @@ -1,8 +1,10 @@ import { SiteFooter } from "@coss/ui/shared/site-footer"; import type { Metadata } from "next"; import { ChatShowcase } from "./chat-showcase"; +import { absoluteUrl } from "@/lib/canonical"; export const metadata: Metadata = { + alternates: { canonical: absoluteUrl("/chat") }, title: "Chat UI — Make room for conversation — coss ui", description: "Beautifully crafted React chat components. Explore replies, reactions, mentions, and every state in between. Built with Base UI, Tailwind CSS, and Motion.", diff --git a/apps/ui/app/docs/[[...slug]]/page.tsx b/apps/ui/app/docs/[[...slug]]/page.tsx index 6946d956ea..fa67cbb765 100644 --- a/apps/ui/app/docs/[[...slug]]/page.tsx +++ b/apps/ui/app/docs/[[...slug]]/page.tsx @@ -8,6 +8,7 @@ import { ScrollArea } from "@/registry/default/ui/scroll-area"; import { DocsCopyPage } from "@/components/docs-copy-page"; import { DocsTableOfContents } from "@/components/docs-toc"; import { SiteFooter } from "@/components/site-footer"; +import { absoluteUrl } from "@/lib/canonical"; import { source } from "@/lib/source"; import { mdxComponents } from "@/mdx-components"; @@ -36,6 +37,7 @@ export async function generateMetadata(props: { } return { + alternates: { canonical: absoluteUrl(page.url) }, description: doc.description, title: `${doc.title} - coss ui`, }; diff --git a/apps/ui/app/page.tsx b/apps/ui/app/page.tsx index d045079857..66e2a92199 100644 --- a/apps/ui/app/page.tsx +++ b/apps/ui/app/page.tsx @@ -20,6 +20,7 @@ import { getCategoryThumbnail } from "@/components/category-thumbnails"; import { PrimitivesBlueprint } from "@/components/primitives-blueprint"; import { PrimitivesMotion } from "@/components/primitives-motion"; import { categories } from "@/config/categories"; +import { absoluteUrl } from "@/lib/canonical"; import { PAGES_NEW } from "@/lib/docs"; const description = @@ -27,6 +28,7 @@ const description = const particleCount = particles.length; export const metadata: Metadata = { + alternates: { canonical: absoluteUrl("/") }, description, title: "A modern React UI component library – coss ui", }; diff --git a/apps/ui/app/particles/page.tsx b/apps/ui/app/particles/page.tsx index 7cfefb4722..dd5d2b572d 100644 --- a/apps/ui/app/particles/page.tsx +++ b/apps/ui/app/particles/page.tsx @@ -11,12 +11,15 @@ import { ParticlesDisplay } from "./particles-display"; import SearchContainer from "./search-container"; import { ParticlesBlueprint } from "@/components/particles-blueprint"; import { ParticlesMotion } from "@/components/particles-motion"; +import { absoluteUrl } from "@/lib/canonical"; const particleCount = particles.length; const description = `Explore ${particleCount} ready-to-use UI patterns built from coss ui components. Copy the code, customize the details, and make them part of your product.`; export const metadata: Metadata = { + // Filtered views (?tags=…) are the same page. + alternates: { canonical: absoluteUrl("/particles") }, description, title: "Build more with Particles – coss ui", }; diff --git a/apps/ui/app/sitemap.ts b/apps/ui/app/sitemap.ts index 14ddc1138b..4dcaf6e201 100644 --- a/apps/ui/app/sitemap.ts +++ b/apps/ui/app/sitemap.ts @@ -1,15 +1,16 @@ import type { MetadataRoute } from "next"; +import { absoluteUrl } from "@/lib/canonical"; import { source } from "@/lib/source"; export default function sitemap(): MetadataRoute.Sitemap { const pages = source.getPages(); return [ - { url: "https://coss.com/ui" }, - { url: "https://coss.com/ui/particles" }, - { url: "https://coss.com/ui/chat" }, + { url: absoluteUrl("/") }, + { url: absoluteUrl("/particles") }, + { url: absoluteUrl("/chat") }, ...pages.map((page) => ({ - url: `https://coss.com/ui${page.url}`, + url: absoluteUrl(page.url), })), ]; } diff --git a/apps/ui/lib/canonical.ts b/apps/ui/lib/canonical.ts new file mode 100644 index 0000000000..5c589babb4 --- /dev/null +++ b/apps/ui/lib/canonical.ts @@ -0,0 +1,11 @@ +import { appConfig } from "@/lib/config"; + +/** + * A page's absolute URL on coss.com, exactly as the sitemap lists it: the + * basePath included, no trailing slash. Pages use it as their canonical, so + * copies of a page (query strings, preview deployments, raw Markdown) all + * point search engines at one URL. + */ +export function absoluteUrl(path = "/"): string { + return path === "/" ? appConfig.url : `${appConfig.url}${path}`; +} From 87e64bab82512d9795790068e4c5ed10d5e26bd2 Mon Sep 17 00:00:00 2001 From: Bailey Pumfleet Date: Mon, 23 Nov 2026 12:47:10 -0600 Subject: [PATCH 2/2] feat: link coss.com from the coss ui and Origin footers The footers say who funds the project and link coss.com's products, docs and blog with plain links (another zone, so no client routing). --- apps/origin/components/footer.tsx | 44 +++++++++++++++++++++++--- apps/ui/components/site-footer.tsx | 35 ++++++++++++++++++-- packages/ui/src/shared/site-footer.tsx | 44 +++++++++++++++++++++----- 3 files changed, 108 insertions(+), 15 deletions(-) diff --git a/apps/origin/components/footer.tsx b/apps/origin/components/footer.tsx index af5f8efe3b..2b8c40174d 100644 --- a/apps/origin/components/footer.tsx +++ b/apps/origin/components/footer.tsx @@ -1,3 +1,15 @@ +const COSS_URL = "https://coss.com"; + +/** coss.com's pages worth knowing about, linked from the footer. */ +const COSS_LINKS = [ + { href: "/products", label: "Products" }, + { href: "/products/email", label: "Email API" }, + { href: "/products/sms", label: "SMS API" }, + { href: "/products/scheduling", label: "Scheduling API" }, + { href: "/docs", label: "Docs" }, + { href: "/blog", label: "Blog" }, +]; + export default function Footer() { return (
@@ -5,10 +17,34 @@ export default function Footer() { aria-hidden="true" className="before:absolute before:-top-px before:-left-12 before:z-10 before:-ml-px before:size-[3px] before:bg-ring/50 after:absolute after:-top-px after:-right-12 after:z-10 after:-mr-px after:size-[3px] after:bg-ring/50" /> -
-

- © {new Date().getFullYear()} coss.com -

+
+
+

+ Free and open source, funded by{" "} + + coss.com + + : one API for email, SMS, scheduling and more. +

+

© {new Date().getFullYear()} coss.com

+
+
); diff --git a/apps/ui/components/site-footer.tsx b/apps/ui/components/site-footer.tsx index 5deaa032e6..9e66bcda2b 100644 --- a/apps/ui/components/site-footer.tsx +++ b/apps/ui/components/site-footer.tsx @@ -1,6 +1,9 @@ export function SiteFooter() { - const gatewayOrigin = process.env.NEXT_PUBLIC_COSS_URL || "https://coss.com"; - const gatewayHome = `${gatewayOrigin.replace(/\/$/, "")}/`; + const gatewayOrigin = ( + process.env.NEXT_PUBLIC_COSS_URL || "https://coss.com" + ).replace(/\/$/, ""); + const gatewayHome = `${gatewayOrigin}/`; + const linkClassName = "font-medium underline-offset-4 hover:underline"; return ( ); } diff --git a/packages/ui/src/shared/site-footer.tsx b/packages/ui/src/shared/site-footer.tsx index 8096196642..cb815209d5 100644 --- a/packages/ui/src/shared/site-footer.tsx +++ b/packages/ui/src/shared/site-footer.tsx @@ -1,6 +1,17 @@ +/** coss.com's pages worth knowing about, linked from the footer. */ +const COSS_LINKS = [ + { href: "/products", label: "Products" }, + { href: "/products/email", label: "Email API" }, + { href: "/products/sms", label: "SMS API" }, + { href: "/products/scheduling", label: "Scheduling API" }, + { href: "/docs", label: "Docs" }, + { href: "/blog", label: "Blog" }, +]; + export function SiteFooter() { - const gatewayOrigin = process.env.NEXT_PUBLIC_COSS_URL || "https://coss.com"; - const gatewayHome = `${gatewayOrigin.replace(/\/$/, "")}/`; + const gatewayOrigin = ( + process.env.NEXT_PUBLIC_COSS_URL || "https://coss.com" + ).replace(/\/$/, ""); return ( );