Canonical through the meta export
A relative canonical resolves differently depending on the requested URL, which is exactly the ambiguity a canonical exists to remove. Check meta-canonical-absolute
import type { MetaFunction } from "react-router";
const SITE = "https://www.example.com";
export const meta: MetaFunction = ({ location }) => {
const canonical = SITE + location.pathname.replace(/\/$/, "");
return [
{ title: "Pricing | Acme" },
{ name: "description", content: "Three tiers, one-time payment." },
{ tagName: "link", rel: "canonical", href: canonical },
{ property: "og:url", content: canonical },
];
};