GraphQL

The GraphQL API is a great way to integrate Advanced SEO with your headless front end.

Enable GraphQL

Enable GraphQL in the addon's config:

'graphql' => true,

SEO Fields

The Advance SEO data of your entries and terms is separated into three distinct fields:

The easiest way to get the data is to use the seo field on Statamic's existing entries, entry, terms, and term queries:

{
  entry(id: "1d366a68-855e-4145-81ea-87174826a4eb") {
    seo {
      computed {
        title
      }
      raw {
        description
      }
      views {
        body
      }
    }
  }
}

Available Queries

SEO Meta

The seoMeta query is an alternative to using the seo field on the entries, entry, terms, and term queries.

Get the computed title of an entry:

{
  seoMeta(id: "1d366a68-855e-4145-81ea-87174826a4eb") {
    computed {
      title
    }
  }
}

Get the computed title of the brands term of the tags taxonomy in the german site:

{
  seoMeta(id: "tags::brands", site: "german") {
    computed {
      title
    }
  }
}

SEO Defaults

Use the seoDefaults query to get the default data. The query consists of three fields:

Site Defaults

Get the site_name from the general site defaults:

{
  seoDefaults {
    site {
      general {
        site_name
      }
    }
  }
}

Get the data from the german site:

{
  seoDefaults {
    site(site: "german") {
      general {
        site_name
      }
    }
  }
}

Collection Defaults

Get the title from the pages collection defaults:

{
  seoDefaults {
    collection(handle: "pages") {
      title
    }
  }
}

Get the data from the german site:

{
  seoDefaults {
    collection(handle: "pages", site: "german") {
      title
    }
  }
}

Taxonomy Defaults

Get the title from the tags taxonomy defaults:

{
  seoDefaults {
    taxonomy(handle: "tags") {
      title
    }
  }
}

Get the data from the german site:

{
  seoDefaults {
    taxonomy(handle: "tags", site: "german") {
      title
    }
  }
}

SEO Sitemaps

Use the seoSitemaps query to get the data of your collection, taxonomy, and custom sitemaps. The query consists of three fields sharing the same structure:

Get the loc of all collection, taxonomy, and custom sitemaps:

{
  seoSitemaps {
    collection {
      loc
    }
    taxonomy {
      loc
    }
    custom {
      loc
    }
  }
}

Last updated