Author image not displaying in Sanity blog post query
Looking at your code, the issue is that you're querying author->{name, picture} but picture is likely an image object that needs to be expanded to get its URL, just like you did with coverImage.
Your GROQ query needs to expand the author's picture asset reference to get the actual image URL:
export async function getPosts(): Promise<Post[]> {
return createClient(clientConfig).fetch(
groq`*[_type == "post"]{
_id,
_createdAt,
title,
"slug": slug.current,
alt,
excerpt,
"coverImage": coverImage.asset->url,
date,
"author": author->{
name,
"picture": picture.asset->url
},
}`
);
}The key change is "picture": picture.asset->url inside the author projection. This follows the same pattern you're already using for coverImage - you need to dereference the asset with -> and get its url property.
In Sanity, image fields store a reference to an asset document, not the URL directly. The asset->url syntax:
asset- accesses the asset reference in the image object->- dereferences/follows that reference to the actual asset documenturl- grabs the URL property from that asset document
This is a common gotcha when working with nested references in GROQ! Your schema and component code look fine - it was just the query that needed the fix.
Show original thread11 replies
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.