Skip to content

og:url and canonical mismatch

The og:url meta tag and the <link rel="canonical"> tag both declare the preferred URL for this page. When they disagree, you create conflicting signals: social platforms use og:url to attribute shares, while search engines use canonical to consolidate link equity. The two should always be identical.

A common cause is setting og:url to the bare domain (https://example.com) while the canonical correctly includes a trailing slash or path (https://example.com/).

Set both og:url and canonical to the exact same URL. Choose one canonical form, either with or without a trailing slash, and use it everywhere.

<!-- Both must match exactly -->
<link rel="canonical" href="https://example.com/" />
<meta property="og:url" content="https://example.com/" />

Use the metadataBase and alternates.canonical approach. Next.js derives og:url from the openGraph.url field.

app/layout.tsx
export const metadata = {
metadataBase: new URL('https://example.com'),
alternates: {
canonical: '/',
},
openGraph: {
url: 'https://example.com/',
},
}

For pages with specific paths:

app/about/page.tsx
export const metadata = {
alternates: {
canonical: '/about',
},
openGraph: {
url: 'https://example.com/about',
},
}

Set both tags in <Head> and ensure they use the same value.

import Head from 'next/head'
const CANONICAL = 'https://example.com/about'
export default function About() {
return (
<>
<Head>
<link rel="canonical" href={CANONICAL} />
<meta property="og:url" content={CANONICAL} />
</Head>
<main>Content</main>
</>
)
}
<script>
const canonical = 'https://example.com/about'
</script>
<svelte:head>
<link rel="canonical" href={canonical} />
<meta property="og:url" content={canonical} />
</svelte:head>
<script setup>
const canonical = 'https://example.com/about'
useHead({
link: [{ rel: 'canonical', href: canonical }],
})
useSeoMeta({
ogUrl: canonical,
})
</script>
src/layouts/Layout.astro
---
interface Props {
title: string
canonical: string
}
const { title, canonical } = Astro.props
---
<!doctype html>
<html lang="en-GB">
<head>
<title>{title}</title>
<link rel="canonical" href={canonical} />
<meta property="og:url" content={canonical} />
</head>
<body><slot /></body>
</html>
<head>
<link rel="canonical" href="https://example.com/about" />
<meta property="og:url" content="https://example.com/about" />
</head>
Terminal window
curl -s https://example.com | grep -iE 'canonical|og:url'

Both values should be identical. Re-run the audit:

Terminal window
npx orino audit https://example.com