Next.js Discord

Discord Forum

Metadata og:url

Unanswered
Long-legged ant posted this in #help-forum
Open in Discord
Long-legged antOP
Is there a way (with App Router) to set the current URL as url in the metadata, without middleware or turning every page to SSR?

3 Replies

i supposed in worst case you can do something like
"use client";

const pathname = usePathname();
return <meta property="og:url" content={`${domain}${pathname}`} />;
but i just hardcode the value
there aren't that many pages to hardcode anyway, most pages will be dynamic params where you can automatically populate the value in generateMetadata