The Open Graph protocol

Протокол, имащ идея да стандартизира начинът, по който дадена web страница да бъде споделяна в различните социални мрежи като Facecbook, така че да бъде т.н. „rich object in a social graph“.

Тоест, да предостави хем достатъчно, хем минимална информация за себе си, за да може например Facebook да знае ако ще и малко, но поне достатъчно, за да я включи успешно в своя т.н. „sociql graph“.

Как става това?

Просто като в секцията на web страницата се добавят определени тагове с 4 задължителни атрибута:
og:title – The title of your object as it should appear within the graph, e.g., „The Rock“.
og:type – The type of your object, e.g., „video.movie“. Depending on the type you specify, other properties may also be required.
og:image – An image URL which should represent your object within the graph.
og:url – The canonical URL of your object that will be used as its permanent ID in the graph, e.g., „https://www.imdb.com/title/tt0117500/“.

<html prefix="og: https://ogp.me/ns#">
<head>
<title>The Rock (1996)
<meta property="og:title" content="The Rock">
<meta property="og:type" content="video.movie">
<meta property="og:url" content="https://www.imdb.com/title/tt0117500/">
<meta property="og:image" content="https://ia.media-imdb.com/images/rock.jpg">
…
</head>
…
</html>

Има разбира се и незадължителни атрибути:
og:audio – A URL to an audio file to accompany this object.
og:description – A one to two sentence description of your object.
og:determiner – The word that appears before this object’s title in a sentence. An enum of (a, an, the, „“, auto). If auto is chosen, the consumer of your data should chose between „a“ or „an“. Default is „“ (blank).
og:locale – The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.
og:locale:alternate – An array of other locales this page is available in.
og:site_name – If your object is part of a larger web site, the name which should be displayed for the overall site. e.g., „IMDb“.
og:video – A URL to a video file that complements this object.

Ето техният HTML пример:

<meta property="og:audio" content="https://example.com/bond/theme.mp3">
<meta property="og:description" content="Sean Connery found fame and fortune as the suave, sophisticated British agent, James Bond.">
<meta property="og:determiner" content="the">
<meta property="og:locale" content="en_GB">
<meta property="og:locale:alternate" content="fr_FR">
<meta property="og:locale:alternate" content="es_ES">
<meta property="og:site_name" content="IMDb">
<meta property="og:video" content="https://example.com/bond/trailer.swf">

Отделно, някои от атрибутите могат да имат допълнитела мета информация. Например за og:image можем да имаме:
og:image:url – Identical to og:image.
og:image:secure_url – An alternate url to use if the webpage requires HTTPS.
og:image:type – A MIME type for this image.
og:image:width – The number of pixels wide.
og:image:height – The number of pixels high.
og:image:alt – A description of what is in the image (not a caption). If the page specifies an og:image it should specify og:image:alt.

HTML пример:

<meta property="og:image" content="https://example.com/ogp.jpg">
<meta property="og:image:secure_url" content="https://secure.example.com/ogp.jpg">
<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:width" content="400">
<meta property="og:image:height" content="300">
<meta property="og:image:alt" content="A shiny red apple with a bite taken out">

Подобно и заз og:video, за og:audio…

Друго интересно е, че даден таг с дадено property може да има повече от една стойност.
Например:

<meta property="og:image" content="https://example.com/rock.jpg">
<meta property="og:image" content="https://example.com/rock2.jpg"> 

Литература:

https://ogp.me/