Sharing a Web Page
Last Tended:
Status: seed
Open Graph protocol
The Open Graph protocol enables a web page to become a rich object in a social graph. Some sites that allow posting (like Facebook), use this protocol (or a variation of it) to display an image & other meta information about a web page when a URL is added to the post. Example of a rich object on Twitter:
Common Open Graph HTML elements required on the web page to enable this:
/index.html
Elements required to render a Twitter Card when sharing a web page on Twitter post:
/index.html
Elements required to render a share card when sharing a web page in a LinkedIn post:
/index.html
Publish date
In order for a LinkedIn post to register a publish date, a time element needs to be on the page with a datetime
attribute.
Its value needs to be in ISO 8601 format.
/index.html
To convert a date into this format, use .toISOString()
:
/index.js
Console
Image Size
Twitter's documentation details minimum & maximum image size but doesn't recommend a size or aspect ratio (for either summary or summary_large_image).
Twitter's card displays a summary_large_image
image at 504 x 264px (1.91:1 ratio) on desktop.
The only recommendation I could find was from Neil Patel who recommends 1200 x 627px (1.91:1 ratio).
This is consistent with LinkedIn's share image recommendation.
The displayed image size doesn't adapt if an image with a different ratio is provided, even with accurate og:image:height
og:image:height
values.
A Twitter 1200 x 600px share image (cut-off at the sides):
A LinkedIn 1200 x 600px share image (cut-off at the sides):
A Twitter 1200 x 627px share image (not cut-off):
Design
It's common to see meta information, such as the page title, within a share image. Considering most platforms will display meta information along with the image when sharing, I think this approach is duplicating information, resulting in poor UX (User Experience).