Sherif
Sherif

Reputation: 359

HTML Validation for facebook OpenGraph tags

I have been told that I can use the opengraph, and other FB/Twitter protocols inside a javascript write function, with CDATA, so that the validator skips it, but it still operates. I just really need someone to look at the below code and confirm I'm not doing something wrong, if you'd be so kind!

<script type="text/javascript">
//<![CDATA[
document.write("<meta property=\"og:image\" content=\"http://myurl.com/logo.png\" />");
//]]>
</script>

It validates, but now I am not sure if Facebook will actually see it.

Thank you!

Upvotes: 0

Views: 398

Answers (2)

Jeff Sherlock
Jeff Sherlock

Reputation: 3544

This won't work. The FB scraper doesn't execute any javascript.

Upvotes: 3

Florian
Florian

Reputation: 800

You can test your site with Facebook's own validator: https://developers.facebook.com/tools/debug

Upvotes: 1

Related Questions