OpenGraph

HTML & web

Open Graph and Twitter Card meta tags for HTML documents.

Use these in your page <head> so chat apps and social sites can show a title, description, and image when someone shares a link. Pair with Rss when you also want a feed, and write pages with selm export.

Html.node "head"
    []
    (Html.node "title" [] [ Html.text "Docs" ]
        :: OpenGraph.website
            { title = "Docs"
            , description = "Learn selm"
            , url = "https://example.com/docs/"
            , image = Just "https://example.com/og.png"
            , siteName = Just "selm"
            }
    )

Types

Tags

type alias Tags =
{ title : String
, description : String
, url : String
, image : Maybe String
, siteName : Maybe String
, type_ : String
}

Fields for Open Graph / Twitter Card tags.

type_ is the Open Graph object type ("website", "article", ...). image and siteName are omitted from the markup when Nothing.

Values

website

website : { title : String , description : String , url : String , image : Maybe String , siteName : Maybe String } -> List (Html msg)

Meta tags for a generic website page (og:type is "website").

Examples

OpenGraph.website
    { title = "selm"
    , description = "Friendly Elm for the BEAM"
    , url = "https://example.com/"
    , image = Just "https://example.com/og.png"
    , siteName = Just "selm"
    }

tags

tags : Tags -> List (Html msg)

Render Open Graph, Twitter Card, and plain description meta tags.

Examples

OpenGraph.tags
    { title = "Quick start"
    , description = "Install and run selm"
    , url = "https://example.com/docs/quick-start/"
    , image = Nothing
    , siteName = Just "selm"
    , type_ = "article"
    }