Sanity changes visible in preview but not publishing

7 replies
Last updated: May 6, 2021
Hello - not sure if this is the right forum but somehow changes that are made in sanity are not published, but are seen in preview. Any ideas? We have two different sanity versions, and this is one that has not been used for some time. Thanks
AI Update

This sounds like a classic draft vs. published content issue! When you're seeing changes in preview but not in production, it typically means your preview is looking at draft documents while your production site is querying only published documents.

Here's what's likely happening:

The Draft/Published System

When you make changes to content in Sanity Studio, those changes are saved as draft documents with an ID prefixed by drafts. (like drafts.post-123). The published version remains unchanged until you explicitly click the "Publish" button in the Studio. This means both versions can exist simultaneously.

Common Causes & Solutions:

  1. Changes weren't published - The most common reason! After editing in the Studio, make sure you're clicking the "Publish" button (not just saving). Look for the green "Publish" button in the document editor.

  2. Your production queries are using the wrong perspective - If you're using the newer API version 2025-02-19, the default perspective changed to published (which excludes drafts). Your preview might be using previewDrafts perspective while production uses published.

  3. GROQ queries filtering out drafts - Check if your production queries explicitly exclude drafts with patterns like:

    *[_type == 'post' && !(_id in path("drafts.**"))]
  4. Stale project after long inactivity - Since you mentioned this project hasn't been used for a while, try:

    • Refreshing your Studio (sanity upgrade if needed)
    • Checking if your frontend is still properly connected to the right dataset
    • Verifying your API token/credentials are still valid

Quick Debug Steps:

  1. In Studio, open a document that should be published and verify it shows "Published" status (not just "Saved")
  2. Try querying your content directly via Vision plugin in Studio to see what's actually in your dataset
  3. Check your frontend code to see which perspective it's using for production queries

If you're still stuck, checking the Vision plugin will quickly show you whether the published documents exist in your Content Lake or if they're still only in draft state.

Show original thread
7 replies
Hi
user U
đź‘‹ Sorry to hear your changes are not coming through. When you say they are not published, are you referring to not being able to publish documents inside the Sanity Studio or rather not seeing the changes reflected on a web front-end, for example?
Also, is this in local development or in production? If it's in production, is the site successfully rebuilding after you publish your changes?
user M
- hello, I am changing an element in the studio, see the text coming through in “Open Preview” . However, after having clicked “Publish”, I do not see the change on the website.
This may be because whereas the preview is real-time, the change to your production (live) site relies on a build process to complete.
The preview loads the updated data from the Sanity Content Lake (our APIs) when you open it from the studio. However, the live site may only fetch the data on build, which means a publish action either triggers a rebuild of the site (which usually takes a few minutes to complete) or does not trigger anything and relies on you or one of your developers triggering a rebuild yourself.

This depends on the website's implementation and not the Sanity Studio per se. Where are you hosting the site (e.g. Vercel or Netlify)?
This may be because whereas the preview is real-time, the change to your production (live) site relies on a build process to complete.
The preview loads the updated data from the Sanity Content Lake (our APIs) when you open it from the studio. However, the live site may only fetch the data on build, which means a publish action either triggers a rebuild of the site (which usually takes a few minutes to complete) or does not trigger anything and relies on you or one of your developers triggering a rebuild yourself.

This depends on the website's implementation and not the Sanity Studio per se. Where are you hosting the site (e.g. Vercel or Netlify)?
Thanks for the clarification. I am just a “content writer” so this is helpful. Do I understand correctly that I should raise this with our interal developers as Sanity studio works as it should (Open preview shows correctly). I don’t know where we are hosting the site unfortunately.
That's right, I'd recommend getting in touch with the devs to ask them to rebuild the site as you've updated its content. Alternatively, perhaps they could explain a way for you to trigger these rebuilds yourself [or do them automatically] depending on how they set things up. They should also feel free to reach out to us here in case they have questions 🙂
Thanks Peter!

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.

Was this answer helpful?