View Source SEO.OpenGraph (SEO v0.1.11)

Build OpenGraph tags. This is consumed by platforms such as Google, Facebook, Twitter, Slack, and others.

For example, the following is the OpenGraph markup for the movie "The Rock" on IMDB:

<html>
<head>
<title>The Rock (1996)</title>
<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>

Resources

Summary

Types

language code and territory code, eg: en_US

The word that appears before this item's title in a sentence.

t()

Functions

Represent your items on the graph of the internet. 🤩🌐📄

Attributes

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

Types

language_territory()

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

language code and territory code, eg: en_US

open_graph_determiner()

@type open_graph_determiner() :: :a | :an | :the | :auto | nil

The word that appears before this item's title in a sentence.

If :auto is chosen, the consumer of your data should chose between "a" or "an".

t()

@type t() :: %SEO.OpenGraph{
  audio: URI.t() | String.t() | SEO.OpenGraph.Audio.t() | nil,
  description: String.t() | nil,
  detail:
    SEO.OpenGraph.Article.t()
    | SEO.OpenGraph.Profile.t()
    | SEO.OpenGraph.Book.t()
    | nil,
  determiner: open_graph_determiner(),
  image: URI.t() | String.t() | SEO.OpenGraph.Image.t() | nil,
  locale: language_territory() | nil,
  locale_alternate: language_territory() | [language_territory()] | nil,
  site_name: String.t() | nil,
  title: String.t(),
  type_detail: term(),
  url: URI.t() | String.t(),
  video: URI.t() | String.t() | SEO.OpenGraph.Video.t() | nil
}

Functions

build(attrs, default \\ nil)

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

Represent your items on the graph of the internet. 🤩🌐📄

Basic Metadata

The four required properties for every page are:

  • :title - The title of your item as it should appear within the graph, e.g., "The Rock".
  • :detail - The detail of your item, e.g., %SEO.OpenGraph.Article{}.
  • :image - An image URL or SEO.OpenGraph.Image that represents your item within the graph.
  • :url - The canonical URL of your item that will be used as its permanent ID in the graph, e.g., https://www.imdb.com/title/tt0117500/. Ultimately, this is where the programs will scrape for metadata. For example, if you use a url of a YouTube video page, the scraper will use the OpenGraph tags found on that video page and not the currently-visited site.

Optional Metadata

The following properties are optional for any item and are generally recommended:

  • :audio - A URL to a complementing audio file. You may also be more detail with SEO.OpenGraph.Audio
  • :description - A one to two sentence description of your item.
  • :determiner - The word that appears before this item's title in a sentence. An enum of :a, :an, :the, nil, :auto. If :auto is chosen, the consumer of your data should chose between :a or :an.
  • :locale - The locale these tags are marked up in. Of the format language_TERRITORY. Unsupplied is consumed as "en_US".
  • :locale_alternate - A list of other locales this page is available in and their URLs.
  • :site_name - If your item is part of a larger web site, the name which should be displayed for the overall site. e.g., "IMDb".
  • :video - A URL to a complementing video file. You may also provide more detail with SEO.OpenGraph.Video

meta(assigns)

Attributes

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