Creating a meta description for an article using API

Hey,

I’m trying to create an article on a blog using the graphQL Admin API from shopify, and I want to add a meta description using the api.

I’m using articleCreate for everything else, and that works, but I don’t see a way to add a meta description to a specific article.

Thanks for the help!

1 Like

You can’t set the meta description directly through the articleCreate mutation — it’s actually handled through the seo field, which is part of the OnlineStoreArticleInput object. You can include it like this:

mutation {
  articleCreate(
    blogId: "gid://shopify/OnlineStoreBlog/123456789",
    article: {
      title: "My New Article"
      bodyHtml: "<p>Some content here</p>"
      seo: {
        title: "Custom SEO Title"
        description: "This is the meta description shown in search results."
      }
    }
  ) {
    article {
      id
      title
      seo {
        title
        description
      }
    }
    userErrors {
      field
      message
    }
  }
}

That seo.description value maps exactly to the “Meta description” field shown in your screenshot. You can find more details in the Shopify Admin GraphQL API docs for OnlineStoreArticleInput and SEOInput.

If you ever need to update it later, you can use articleUpdate with the same seo field structure.

Thanks for the answer, but it doesn’t work. I don’t see the SEO field in the ArticleCreateInput and I don’t see the OnlineStoreArticleInput object.

This is the error I’m getting:

Field ‘seo’ doesn’t exist on type ‘Article’
locations
0
line:1
column:127
path
0:mutation CreateArticle
1:articleCreate
2:article
3:seo
extensions
code:undefinedField
typeName:Article
fieldName:seo

As mentioned, this does not exist on ArticleCreateInput, please do check what you’re posting first.

So its not possible to do it in any way? Only manually once the blog is uploaded?

This is not related to the OP’s original post.