Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Discussion on importing and publishing documents in Sanity, with some confusion around the "Publish" vs "Published" status.

28 replies
Last updated: Jun 8, 2021
Hi there, I just want to confirm if I import lots of documents using sanity/client is there any way to publish them or we have to go into Sanity and update them individually?
Jun 6, 2021, 5:05 AM
I think if you import them they’ll be published by default - unless they’re imported with the IDs having a
draft.*
prefix. Been a while since I’ve done it though so not 100% sure!
Jun 6, 2021, 2:09 PM
Thank you I'll look into what you are saying.
Jun 6, 2021, 7:09 PM
createOrReplace
Jun 7, 2021, 7:50 PM
also is there anything special i need to do to slug?
Jun 7, 2021, 7:51 PM
This is how I'm doing it `"slug": { "_type": "slug",
"_key": "nura-loop",
"title": "nura-loop",
"current": "nura-loop"
},
Jun 7, 2021, 7:51 PM
One more question I have I'll ask in the main channel since it's a bit different
Jun 7, 2021, 7:53 PM
Circling back to this, are the documents showing up as drafts in your studio or are they not being reflected in your frontend?
Jun 8, 2021, 4:41 PM
Circling back to this, are the documents showing up as drafts in your studio or are they not being reflected in your frontend?
Jun 8, 2021, 4:41 PM
Awww we don't have a frontend yet. They are showing up in the browser when you run
sanity start
and then look at localhost:3333, but they don't say 'published'. Sometimes they are green and say Publish (this I managed to have happen when I changed the slug code to the above (2 texts above this one). I will try to query them with graphql in a few hours. (it's early here I'm in Melbourne, Aus). And I just need to do a couple other things first.
Jun 8, 2021, 7:14 PM
It's not consistent though btw. I can't really figure out about why sometimes they are green with Publish and sometimes I have to click on Generate for the slug, even after doing the above code.
Jun 8, 2021, 7:15 PM
can you share some screen shots of what the different issues look like?
Jun 8, 2021, 7:20 PM
definitely. thanks for looking into this. I'll see if I can quickly do it now.
Jun 8, 2021, 7:22 PM
this is one that does not have a reference to anything else
Jun 8, 2021, 7:25 PM
{
  "_createdAt": "2021-06-07T09:59:21Z",
  "_id": "c9fa2207-99bc-4c57-9dbf-30181de81777",
  "_rev": "456kRT8Yu2eqQJttyIFwox",
  "_type": "quote",
  "_updatedAt": "2021-06-07T10:01:39Z",
  "author": "Sharon Stratsianis",
  "quote": "This is sound you can feel."
}

Jun 8, 2021, 7:26 PM
That is what I get when I use. your inspect tool
Jun 8, 2021, 7:26 PM
This is my data I am importing
Jun 8, 2021, 7:28 PM
[ {
"_id": "c9fa2207-99bc-4c57-9dbf-30181de81777",
"_type": "quote",
"author": "Sharon Stratsianis",
"quote": "This is sound you can feel.",
"_rev": "cmoitz-35m-soo-280-ijmk3acri",
"_updatedAt": "2021-06-07T08
:03:44.540Z" }
]
Jun 8, 2021, 7:28 PM
And lastly here is the schema
Jun 8, 2021, 7:29 PM
export default { name: 'quote',
title: 'Quote',
type: 'document',
hidden: true,
fields: [
{
name: 'author',
title: 'Author',
type: 'string',
validation: (Rule) => Rule.required()
},
{
name: 'quote',
title: 'Quote',
type: 'string',
validation: (Rule) => Rule.required()
}
]
}
Jun 8, 2021, 7:29 PM
It does have these 2 validation rules though. So potentially it has to do with the 'weak'/'strong' thing we were talking about.
Jun 8, 2021, 7:30 PM
Nah... I just took at the validation from our schema and reloaded and it still just says publish
Jun 8, 2021, 7:34 PM
and it's not green
Jun 8, 2021, 7:34 PM
Maybe they are "published" even though they say "Publish" in localhost:3333 and not "Published". Because I can see them in graphql deploys playground
Jun 8, 2021, 7:53 PM
Maybe they are "published" even though they say "Publish" in localhost:3333 and not "Published". Because I can see them in graphql deploys playground
Jun 8, 2021, 7:53 PM
When you are in Sanity Studio, imported data is showing up as "Publish" and grey. While if you enter the data yourself in Sanity Studio when you click on the green "Publish" button, it then greys out and says "Published"
Jun 8, 2021, 7:57 PM
Aww, my fault. I have solved my problem LOL. It was just confusing at first because when I was testing I would click on Publish and I would see it said "Published", but now after going through this I see that when you go back to that same document it says "Publish"
Jun 8, 2021, 7:59 PM
Aww, my fault. I have solved my problem LOL. It was just confusing at first because when I was testing I would click on Publish and I would see it said "Published", but now after going through this I see that when you go back to that same document it says "Publish"
Jun 8, 2021, 7:59 PM
Nice! Glad this one got sorted.
Jun 8, 2021, 8:24 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?