View Source SEO.Twitter (SEO v0.1.11)

With Twitter Cards, you can attach rich photos, videos and media experiences to Tweets, helping to drive traffic to your website. Users who Tweet links to your content will have a "Card" added to the Tweet that's visible to their followers.

Examples

Summary card with large image: Summary card with Large Image

Player card: Player card

Resources

Summary

Types

@username for the content creator / author

@username for the website used in the card footer

t()

Functions

Build tags that customize how Twitter displays your page.

Attributes

  • item (SEO.Twitter) - Defaults to nil.
  • config (:any) - Defaults to nil.

Types

creator()

@type creator() :: String.t()

@username for the content creator / author

pixels()

@type pixels() :: pos_integer()

site()

@type site() :: String.t()

@username for the website used in the card footer

t()

@type t() :: %SEO.Twitter{
  app_country: nil | String.t(),
  app_id_googleplay: nil | String.t(),
  app_id_ipad: nil | String.t(),
  app_id_iphone: nil | String.t(),
  app_name_googleplay: nil | String.t(),
  app_name_ipad: nil | String.t(),
  app_name_iphone: nil | String.t(),
  app_url_googleplay: nil | URI.t() | String.t(),
  app_url_ipad: nil | URI.t() | String.t(),
  app_url_iphone: nil | URI.t() | String.t(),
  card: :summary | :summary_large_image | :app | :player,
  creator: nil | creator(),
  creator_id: nil | String.t(),
  description: nil | String.t(),
  image: nil | URI.t() | String.t(),
  image_alt: nil | String.t(),
  player: nil | String.t(),
  player_height: nil | pixels(),
  player_stream: nil | URI.t() | String.t(),
  player_width: nil | pixels(),
  site: nil | site(),
  site_id: nil | String.t(),
  title: nil | String.t()
}

Functions

build(attrs, default \\ nil)

@spec build(SEO.attrs(), SEO.config()) :: t() | nil

Build tags that customize how Twitter displays your page.

  • :card - The different :card types each have a different presentation
    • :summary - card with title, description, and thumbnail.
    • :summary_large_image - similar to the :summary card, but with a prominently-featured image.
    • :app - card with a direct download to a mobile app.
    • :player - card that can display video/audio/media.
  • :creator - The Twitter @username the card should be attributed to.
  • :creator_id - The Twitter id of the user the card should be attributed to.
  • :site - The Twitter @username for the website.
  • :site_id - The Twitter id for the website.
  • :title - A concise title for the related content.
  • :description - A description that concisely summarizes the content as appropriate for presentation within a Tweet.
  • :image - A URL to a unique image representing the content of the page. You should not use a generic image such as your website logo, author photo, or other image that spans multiple pages. Images for this Card support an aspect ratio of 2:1 with minimum dimensions of 300x157 or maximum of 4096x4096 pixels. Images must be less than 5MB in size. JPG, PNG, WEBP and GIF formats are supported. Only the first frame of an animated GIF will be used. SVG is not supported.
  • :image_alt - A text description of the image conveying the essential nature of an image to users who are visually impaired. Maximum 420 characters.
  • :player - HTTPS URL of player iframe
  • :player_width - Width of iframe in pixels
  • :player_height - Height of iframe in pixels
  • :player_stream - URL to raw video or audio stream
  • :app_name_iphone - Name of your iPhone app
  • :app_id_iphone - Your app ID in the iTunes App Store
  • :app_url_iphone - Your app's custom URL scheme
  • :app_name_ipad - Name of your iPad optimized app
  • :app_id_ipad - Your app ID in the iTunes App Store
  • :app_url_ipad - Your app's custom URL scheme
  • :app_name_googleplay - Name of your Android app
  • :app_id_googleplay - Your app ID in the Google Play Store
  • :app_url_googleplay - Your app’s custom URL scheme
  • :app_country - If your application is not available in the US App Store, you must set this value to the two-letter country code for the App Store that contains your application.

If used alongside the OpenGraph tags, the Twitter tags will win when shared on Twitter. If not provided, Twitter will use the OpenGraph tags. Unless you have specific messaging for Twitter followers, it's typically good enough to use OpenGraph for most data.

meta(assigns)

Attributes

  • item (SEO.Twitter) - Defaults to nil.
  • config (:any) - Defaults to nil.