Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple tags (article: tag) in Facebook Open Graph?

For a single blog / article that has multiple tags how would add the Facebook Open Graph data?

This seems like it would be the most logical way to do it. However it reports that it's incorrect in the Facebook debugger:

<meta  property = "article: tag"  content = "advocate, charity, crowdfunding, Healthcare, hospitals, Medical Bills, Medicare, negotiate, uninsured" >

Adding the same above like this seems to be correct, but it seems ridiculous:

<meta property="article:tag" content="advocate" />
<meta property="article:tag" content="charity" />
<meta property="article:tag" content="crowdfunding" />
<meta property="article:tag" content="Healthcare" />
<meta property="article:tag" content="hospitals" />
<meta property="article:tag" content="Medical Bills" />
<meta property="article:tag" content="Medicare" />
<meta property="article:tag" content="negotiate" />
<meta property="article:tag" content="uninsured" />

What is the correct way to do this? Is there a more "optimized" way of writing the above?

like image 379
Bryan Willis Avatar asked Mar 26 '16 00:03

Bryan Willis


1 Answers

As specified in the section about arrays (which the article:tag property definition links to), you have to provide multiple meta elements:

If a tag can have multiple values, just put multiple versions of the same <meta> tag on your page.

If using RDFa in the "intended" way, this would be no big issue because you could mark up each tag where it occurs on the page, e.g.

<ul>
  <li property="article:tag">advocate</li>
  <li property="article:tag">charity</li>
  <li property="article:tag">crowdfunding</li>
</ul>

But if you have to provide the elements in the head element, there is no other solution than to add a separate meta element for each tag.

like image 107
unor Avatar answered Sep 17 '22 12:09

unor