
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeLooking at your queries, I can spot the issue! In your first query, you're filtering for _type == "blogs" (plural), but in your result data, the actual _type value is "blog" (singular), not "blogs".
Here's what's happening:
Your first query:
*[_type == "blogs"]This is returning results, which suggests you might have some documents with _type == "blogs", but the example result you showed has _type: 'blog' (singular).
Your second query:
*[_type == "blogs" && slug.current == $slug][0]This returns null because there's no document with both _type == "blogs" AND slug.current == "another-blog".
The fix:
Change your second query to match the actual type in your data:
export const postQuery = `*[_type == "blog" && slug.current == $slug][0]`;Also, you should probably update your first query for consistency:
export const postsQuery = `*[_type == "blog"]`;The query syntax itself is correct - you're properly using GROQ parameters with the $slug syntax, and passing the parameter correctly. The issue is just the type mismatch between what you're querying for ("blogs") and what actually exists in your data ("blog").
If you're still getting null after this change, double-check:
_type in your Sanity Studio schema'another-blog') exactly matches what's in the document (it looks correct from your example)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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store