Open Graph & Twitter Cards
Learn how to add Open Graph and Twitter Cards to your pages for better social sharing.
Open Graph Overview
Open Graph tags control how your page appears when shared on social media platforms like Facebook, LinkedIn, Slack, and others. Bini.js allows you to define Open Graph metadata directly in your layouts and pages.
Bini.js includes a default og-image.png in the public/ folder. Replace it with your own image to customize your Open Graph and Twitter Card images.
Open Graph Fields
| Field | Type | Description |
|---|---|---|
| title | string | Title for social sharing |
| description | string | Description for social sharing |
| url | string | Canonical URL for the page |
| type | string | Type of content (website, article, etc.) |
| images | array | Array of image objects for social cards |
| siteName | string | Name of the site |
| locale | string | Language locale (e.g., en_US) |
Image object fields:
| Field | Type | Description |
|---|---|---|
| url | string | URL to the image |
| width | number | Width of the image in pixels |
| height | number | Height of the image in pixels |
| alt | string | Alt text for the image |
Twitter Cards Overview
Twitter Cards control how your page appears when shared on Twitter/X. Bini.js supports all Twitter Card types including summary, summary_large_image, app, and player.
Twitter Card Fields
| Field | Type | Description |
|---|---|---|
| card | string | Card type: summary, summary_large_image, app, player |
| title | string | Title for Twitter card |
| description | string | Description for Twitter card |
| creator | string | Twitter handle of the content creator |
| images | array | Array of image URLs for the card |
Card types:
summary— Standard card with a small imagesummary_large_image— Card with a large, prominent imageapp— Card for mobile appsplayer— Card for video/audio content
Complete Example
Here's a comprehensive example combining Open Graph and Twitter Cards for optimal social sharing:
Note: For best results, use images that are at least 1200x630 pixels. This ensures your content looks great on all platforms.