Facebook link sharing allows you to specify a canonical URL for a resource in the HTML metadata for the resource. This is accomplished by using an HTML meta tag to specify the canonical URL for the page. The canonical URL is specified using the og:url
property.
<meta property="og:url" content="https://example.com/path" />
Starting February 3, 2020, you will no longer be able to specify URLs with a different domain as the canonical URL, unless that domain has explicitly added your domain to an allow list using the Webmaster tool.
All links that specify the same canonical URL are treated as the same resource by Facebook's link sharing infrastructure for the purpose of metrics and metadata (link image, title, etc.). You can view engagement metrics for a URL using the Graph API call:
GET /?id={your_url}&fields=engagement
There are a number of scenarios where it might be useful to treat various links on your site as identical. Here are a few examples:
og:url
does not need to be a page that renders in the browser. However, it must respond to the Facebook crawler and return og:*
meta tags. For details on detecting the Facebook crawler, see The Facebook Crawler.og:url
returns an og:url
link that is different, the new link is followed. The sharing details that Facebook uses are the ones at the final link in the redirect chain. The final link in the chain should also include the og:url
meta tag. If og:url
isn't specified, then the URL of the page is assumed to be the canonical URL. The following example demonstrates how to change the URL for a page while preserving the Facebook share link and related metrics. It assumes that the URL for the page has already been changed.
og:url
tag. Set the content attribute to the previous URL value.<meta property="og:url" content="your_old_url" />
<!-- This is the URL for this page --> <meta property="og:url" content="your_old_url" /> <!-- This is the og:* meta from the original version of the page --> <meta property="og:title" content="your_link_title"> <meta property="og:image" content="your_image_url">