Missing displayExcerpt and displayTitle fields on Sanity front page
It sounds like you're working on a front page where you're trying to display post titles and excerpts, but the data isn't showing up. Based on your description, this is likely a GROQ query projection issue where the field names in your query don't match what you're using in your component.
The Problem: When you query for posts on your front page, you need to make sure your GROQ projection uses the same field names (displayTitle and displayExcerpt) that your front-end component is expecting.
Common mistakes:
- Mismatched field names: Your schema fields might be
titleandexcerpt, but you're trying to accessdisplayTitleanddisplayExcerptin your component - Missing projection: You might not be projecting (selecting) these fields in your GROQ query at all
- Incorrect aliasing: If you're renaming fields in your query, the syntax needs to be correct
The fix:
Your GROQ query for the front page should look something like this:
*[_type == "post"]{
"displayTitle": title,
"displayExcerpt": excerpt
}The "displayTitle": title syntax creates an alias - it takes the title field from your schema and renames it to displayTitle in the query results. This is how projections work in GROQ - you can select specific fields and rename them to match what your frontend expects.
If you're working with a starter template (like the Next.js blog starter), the original queries might have used different field names. Make sure:
- Your GROQ query on the front page includes the fields you need in the projection
- The field names in the projection match what your React/Next.js component is trying to access
- If the actual schema fields are named
titleandexcerpt, you either need to alias them in the query (as shown above) OR change your component to usetitleandexcerptinstead ofdisplayTitleanddisplayExcerpt
The query is likely in a file like lib/queries.ts, sanity/lib/queries.ts, or directly in your page component. Double-check that both your front page query and your post page query use the same field naming - if the post page is working, copy that projection structure to your front page query and it should work consistently.
Show original thread14 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.