How to Add Scripts to the Header of the Sanity Studio
Last updated: Nov 13, 2020
Hi out there! I am trying to add a script to the header of the sanity studio, but i can’t seem to find where i can make additions to the <head> element. Can anyone point me in the right direction!
You need to compile the jsx yourself if you override this thing. I've used parcel to do this, but you can use webpack or rollup as well.
parcel build src/Document.js --out-dir lib/
If you do this you get cut off from any future updates to Document.js though, so you should be careful. You could avoid this by using something that's present on all pages, and overwrite that, instead of the complete document. I've found that overriding the logo (
sanity init plugin -> Studio logo
) is the easiest way to load something on every page - so you might be better off using something like that. But that may be the hacker in me speaking.
Nov 12, 2020, 8:57 AM
The hacker in you speaking, speaks to me! I just couldn’t find the entry point. This is what I needed. Many many thanks to you!!!
Nov 12, 2020, 9:15 AM
If anyone else needs help, after
s help I found this script loading example from a sanity plugin