✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Renaming product images for SEO compatibility not reflected in production site, discussion on using originalFilename property in gatsby-source-sanity.

10 replies
Last updated: Nov 2, 2021
I renamed a lot of product images in the studio to make them SEO compatible.Apparently the name changes aren't reflected in the transferred files of the production site though.

I have tried to redeploy clearing cache and have searched through media to check that no other files with the names ending up in production (f.e.
bc4ade6a97553e67ac0e2c336f27004c8c7cd07c-1000x1000.png
) still exist.
Are file name changes only cosmetic for the Studio or do I possibly need to take certain additional steps?
Oct 18, 2021, 11:13 AM
Oct 19, 2021, 9:01 AM
Any input on this?

gatsby-source-sanity
is used in this case.
Oct 25, 2021, 6:46 AM
Hey Leo! Circling back to this. Sanity will always generate a random asset name. For SEO purposes, you can use the
originalFilename
property, as mentioned in this comment. You can find the original filename under
<asset>.originalFilename
. More on the asset object here .
Nov 1, 2021, 7:23 PM
Hey
user M
, thank you for the reply! How exactly should that then be used with
gatsby-source-sanity
?The comment you have linked to doesn't seem to indicate how to actually achieve that solution. I guess it would be possible to construct a url yourself (f.e. through
@sanity/image-url
) and that would mean not relying on the Sanity helper function or the source plugin (directly) for the image?
Nov 1, 2021, 7:28 PM
Ah, that's a good question. I'm not sure on that one, actually. Let me ask internally.
Nov 1, 2021, 7:33 PM
Ah, that's a good question. I'm not sure on that one, actually. Let me ask internally.
Nov 1, 2021, 7:33 PM
Thank you 🙂
Nov 1, 2021, 7:33 PM
It seems like this is really similar to what Christopher was looking to do in this thread. Can you try passing the original name as a parameter?
Nov 1, 2021, 9:19 PM
user M
I think he meant more that being able to pass the original filename as a parameter would be nice to have for the future and that he solved it another way without specifying what his workaround was.
user L
Do you mind me asking, what that workaround was?
Nov 1, 2021, 9:22 PM
I'm actually pulling the images through GraphQL, loading them into an array, and then doing a "lookup" (array key) --not ideal.
Nov 2, 2021, 2:56 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?