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?
You must use link
instead of meta
if the value is a URL.
From the definition of the meta element:
The
meta
element represents various kinds of metadata that cannot be expressed using the […]link
[…] elements.
But a URL can of course be expressed using a link
element (as it’s its purpose).
If you use a meta
element for a URL value, RDFa parsers would extract a string value instead of a URL value. This also means that they wouldn’t be able to apply relative references against the base URL.
Let’s say these elements are in a document with the URL http://example.com/foo
:
The value from the link
element is the URL http://example.com/bar
.
The value from the meta
element is the string /bar
.
The examples in OGP’s documentation use the meta
element for URL values; there is no example with a link
element.
While this means that many of their examples are invalid HTML+RDFa, and RDFa parsers will extract strings instead of URLs in those cases,
it may be the case that Facebook (or any other consumer) isn’t actually using RDFa to parse the content, and it may be the case that they don’t support link
elements.
Note: These are just possibilities, judging from the quality of their documentation. I don’t have any experience/insight, as I don’t use Facebook. So you might want to test it with Facebook if you care about their OGP-based features.