htmlfacebook-opengraphmeta-tagsrdfa

Should og:image and og:url put in <meta> or <link>?


For og:image and og:url, since they have URL, can I place them in a link tag instead of a meta tag, and is it preferable?

Also what is the difference in using these two tags w.r.t. og:image and og:url?


Solution

  • I don't know about other major consumers of the OGP so this might not be a problem for your case, but if you plan to implement it for Facebook,

    stick to meta tags.

    Doing a quick live test with the open graph debugger and fiddling with the og: tags, it appears that facebook only recognizes them if they are placed in <meta>s.

    Try it

    If you create an empty HTML file with a single og:url tag in its <head> section, upload it to any URL and run it through the debugger above, both

    <link rel="og:url" href="http://www.imdb.com/title/tt0117500/" />
    

    and

    <link property="og:url" content="http://www.imdb.com/title/tt0117500/" />
    

    edit or, as suggested in the comments

    <link property="og:url" href="http://www.imdb.com/title/tt0117500/" />
    

    will fail to parse and return the original URL, while

    <meta property="og:url" content="http://www.imdb.com/title/tt0117500/" /> 
    

    parses correctly and returns the contents of The Rock on IMDb instead. At the end of the day semantics are nice, but working code is even better.