Optimize storefront SEO
You can change the way a product, page, collection, blog, or article appears in search engine results by updating the resource's meta tags. The meta tags are the page title and the meta description, which are part of the resource's search engine listing.
For example, when you create a product, the page title and meta description for the product page defaults to the product title and description.
This guide shows you how to change these default values using the GraphQL Admin API's SEO fields.Anchor to RequirementsRequirements
- Your app can make authenticated requests to the GraphQL Admin API.
- There are products, collections, articles, pages or blogs on the store.
- You're familiar with how metafields work.
Anchor to Step 1: Update a resource's search engine listingStep 1: Update a resource's search engine listing
You can update a resource's page title and meta description using the title and description fields in the SEO field.
The following example updates both the title and description for a product's search engine listing:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
You can also query a resource's current SEO settings:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
The SEO field structure is available for Product, Collection, Article, Blog, and Page. Use the appropriate mutation (pageUpdate, collectionUpdate, articleUpdate, blogUpdate, or pageUpdate) with the same seo input structure.
Anchor to Step 2: Hide a resource from search engines and sitemapsStep 2: Hide a resource from search engines and sitemaps
If you want to hide a resource from search engines and sitemaps, then you can use a metafield to automatically add noindex and nofollow meta tags to the resource's pages. To add noindex and nofollow meta tags to a resource's pages, create a new metafield for the resource with the following attributes:
If you hide resources from the sitemap, then they won't appear in search results when customers use storefront search. If you delete the metafield using the GraphQL Admin, then the noindex and nofollow meta tags are removed.
The following example hides a product from search engines and sitemaps:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Next stepsNext steps
- Consult the metafield reference for the GraphQL Admin API.
- Create marketing events for your app to help merchants market products, collections, discounts, and more.