Updating SEO data with the API

You can change the way a product, page, collection, blog, or article appears in search engines by updating the object's SEO data. This can be done by creating or updating metafields.

Update an object's search engine listing

To change an object's search engine listing, you can update two different metafields, title_tag and description_tag. These metafields exist in a namepsace called global. By updating the values of these metafields, you can change the title and description for an object's search engine listing.

Example JSON request

This request would be used to change the description for a product's search engine listing:

POST /admin/products/#{id}/metafields.json
{
  "metafield": {
    "namespace": "global",
    "key": "description_tag",
    "value": "These matte black sunglasses are sure to impress.",
    "value_type": "string"
  }
}

Hide an object from search engines and sitemaps

If you want to hide an object from search engines and sitemaps, then you can use a metafield to add noindex and nofollow meta tags to the object's pages.

To add noindex and nofollow meta tags to an object's pages, create a new metafield for the object with the following attributes:

  • "namespace" : "seo"
  • "key" : "hidden"
  • "value" : 1
  • "value_type" : "integer"

Note

If you hide objects from the sitemap, then they won't appear in search results when customers use storefront search.

Example JSON request

This request would be used to hide a product from search engines and sitemaps:

POST /admin/products/#{id}/metafields.json
{
  "metafield": {
    "namespace": "seo",
    "key": "hidden",
    "value": 1,
    "value_type": "integer"
  }
}