View Source SEO.OpenGraph (SEO v0.1.0)

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

Resources

Link to this section Summary

Types

language code and territory code, eg: en_US

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

The type of OpenGraph object.

t()

Functions

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

Attributes

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

Link to this section Types

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

language code and territory code, eg: en_US

Link to this type

open_graph_determiner()

View Source
@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".

@type open_graph_type() :: :article | :book | :profile | :website

The type of OpenGraph object.

@type t() :: %SEO.OpenGraph{
  audio: URI.t() | String.t() | SEO.OpenGraph.Audio.t() | nil,
  description: String.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: open_graph_type(),
  type_detail: type_detail(),
  url: URI.t() | String.t(),
  video: URI.t() | String.t() | SEO.OpenGraph.Video.t() | nil
}

Link to this section Functions

Link to this function

build(attrs, default \\ nil)

View Source

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

basic-metadata

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".
  • :type - The type of your item, e.g., :article. Depending on the type you specify, other properties may also be required. Default is :website.
  • :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

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

attributes

Attributes

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