Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the 'og' (Open Graph) meta tag for Facebook share

People also ask

How do I add OG tags on Facebook?

Click on 'Social'. Click on the 'Facebook' tab. Toggle the 'Add Open Graph meta data' switch. To enable the feature, toggle the switch to 'On'.

How do I use Open Graph on Facebook?

What does Open Graph protocol do? Through the Open Graph protocol, you can tell Facebook how your shared content should be displayed on Facebook. This protocol tells Facebook which title, URL, image, and description of your blog post/page should be used when your content is shared on Facebook.

How do I share meta tags on Facebook?

Facebook documentation recommends one additional <meta> tag, though it's not required. A tag that denotes the name of the Web site in which the shared page resides: <meta property="og:site_name" content="European Travel, Inc."> This provides an alternative image description for those who are visually impaired.

Where do I put OG meta tags?

If you're comfortable digging into website code, adding OG tags is as straightforward as pasting them into the <head> section of your web page. Consider using a markup generator tool like Mega Tags or Web Code Tools to help reduce syntax errors.


Use:

<!-- For Google -->
<meta name="description" content="" />
<meta name="keywords" content="" />

<meta name="author" content="" />
<meta name="copyright" content="" />
<meta name="application-name" content="" />

<!-- For Facebook -->
<meta property="og:title" content="" />
<meta property="og:type" content="article" />
<meta property="og:image" content="" />
<meta property="og:url" content="" />
<meta property="og:description" content="" />

<!-- For Twitter -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="" />
<meta name="twitter:description" content="" />
<meta name="twitter:image" content="" />

Fill the content =" ... " according to the content of your page.

For more information, visit 18 Meta Tags Every Webpage Should Have in 2013.


Facebook uses what's called the Open Graph Protocol to decide what things to display when you share a link. The OGP looks at your page and tries to decide what content to show. We can lend a hand and actually tell Facebook what to take from our page.

The way we do that is with og:meta tags.

The tags look something like this -

  <meta property="og:title" content="Stuffed Cookies" />
  <meta property="og:image" content="http://fbwerks.com:8000/zhen/cookie.jpg" />
  <meta property="og:description" content="The Turducken of Cookies" />
  <meta property="og:url" content="http://fbwerks.com:8000/zhen/cookie.html">

You'll need to place these or similar meta tags in the <head> of your HTML file. Don't forget to substitute the values for your own!

For more information you can read all about how Facebook uses these meta tags in their documentation. Here is one of the tutorials from there - https://developers.facebook.com/docs/opengraph/tutorial/


Facebook gives us a great little tool to help us when dealing with these meta tags - you can use the Debugger to see how Facebook sees your URL, and it'll even tell you if there are problems with it.

One thing to note here is that every time you make a change to the meta tags, you'll need to feed the URL through the Debugger again so that Facebook will clear all the data that is cached on their servers about your URL.


I built a tool for meta generation. It pre-configures entries for Facebook, Google+ and Twitter, and you can use it free here: http://www.groovymeta.com

To answer the question a bit more, OG tags (Open Graph) tags work similarly to meta tags, and should be placed in the HEAD section of your HTML file. See Facebook's best practises for more information on how to use OG tags effectively.