Head.Seo

https://ogp.me/# https://developers.facebook.com/docs/sharing/opengraph

This module encapsulates some of the best practices for SEO for your site.

elm-pages will pre-render each of the static pages (in your content directory) so that web crawlers can efficiently and accurately process it. The functions in this module are for use with the head function that you pass to your Pages config (Pages.application).

import Date
import Head
import Head.Seo as Seo


-- justinmimbs/date package
type alias ArticleMetadata =
    { title : String
    , description : String
    , published : Date
    , author : Data.Author.Author
    }

head : ArticleMetadata -> List Head.Tag
head articleMetadata =
    Seo.summaryLarge
        { canonicalUrlOverride = Nothing
        , siteName = "elm-pages"
        , image =
            { url = Pages.images.icon
            , alt = articleMetadata.description
            , dimensions = Nothing
            , mimeType = Nothing
            }
        , description = articleMetadata.description
        , locale = Nothing
        , title = articleMetadata.title
        }
        |> Seo.article
            { tags = []
            , section = Nothing
            , publishedTime = Just (Date.toIsoString articleMetadata.published)
            , modifiedTime = Nothing
            , expirationTime = Nothing
            }
type alias Common =
{ title : String
, image : Image
, canonicalUrlOverride : Maybe String
, description : String
, siteName : String
, audio : Maybe Audio
, video : Maybe Video
, locale : Maybe Locale
, alternateLocales : List Locale
, twitterCard : TwitterCard
}

These fields apply to any type in the og object types See https://ogp.me/#metadata and https://ogp.me/#optional

Skipping this for now, if there's a use case I can add it in:

  • og:determiner - The word that appears before this object's title in a sentence. An enum of (a, an, the, "", auto). If auto is chosen, the consumer of your data should chose between "a" or "an". Default is "" (blank).
type alias Image =
{ url : Url
, alt : String
, dimensions :
Maybe
{ width : Int
, height : Int
}
, mimeType : Maybe MimeType
}
{ tags : List String
, section : Maybe String
, publishedTime : Maybe DateOrDateTime
, modifiedTime : Maybe DateOrDateTime
, expirationTime : Maybe DateOrDateTime
}
-> Common
-> List Tag
{ canonicalUrlOverride : Maybe String
, siteName : String
, image : Image
, description : String
, title : String
, audio : Audio
, locale : Maybe Locale
}
-> Common

Will be displayed as a Player card in twitter See: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/player-card

OpenGraph audio will also be included. The options will also be used to build up the appropriate OpenGraph <meta> tags.

Common
-> { tags : List String
, isbn : Maybe String
, releaseDate : Maybe DateOrDateTime
}
-> List Tag
{ firstName : String
, lastName : String
, username : Maybe String
}
-> Common
-> List Tag
Common
-> { duration : Maybe Int
, album : Maybe Int
, disc : Maybe Int
, track : Maybe Int
}
-> List Tag
{ canonicalUrlOverride : Maybe String
, siteName : String
, image : Image
, description : String
, title : String
, locale : Maybe Locale
}
-> Common

Will be displayed as a large card in twitter See: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary

The options will also be used to build up the appropriate OpenGraph <meta> tags.

Note: You cannot include audio or video tags with summaries. If you want one of those, use audioPlayer or videoPlayer

{ canonicalUrlOverride : Maybe String
, siteName : String
, image : Image
, description : String
, title : String
, locale : Maybe Locale
}
-> Common

Will be displayed as a large card in twitter See: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary-card-with-large-image

The options will also be used to build up the appropriate OpenGraph <meta> tags.

Note: You cannot include audio or video tags with summaries. If you want one of those, use audioPlayer or videoPlayer

{ canonicalUrlOverride : Maybe String
, siteName : String
, image : Image
, description : String
, title : String
, video : Video
, locale : Maybe Locale
}
-> Common

Will be displayed as a Player card in twitter See: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/player-card

OpenGraph video will also be included. The options will also be used to build up the appropriate OpenGraph <meta> tags.