πŸ‘€ Our most exciting product launch yet πŸš€ Join us May 8th for Sanity Connect

Creating a custom template for starting new projects in Sanity.io from the CLI.

13 replies
Last updated: Sep 27, 2021
Hi there! Is there the option to init a new project from the cli without creating all the files? Ideally it would even work with a custom template created using sanity-template....
Sep 23, 2021, 4:18 PM
Hi Rachael, thanks for your answer. I'm currently trying to create a template and would like to create new projects from it through the cli...
Sep 24, 2021, 7:08 PM
Got it. You have a few options for using a template, but it sounds like this section on developing a template locally is what you need. There's more info on the
sanity-template
CLI in its repo .
Sep 24, 2021, 7:13 PM
Thanks. I checked the
sanity-template
repo... Well - not all the commands there work for me, but I opened an issue in that regards over at github.
Sep 24, 2021, 7:15 PM
Thanks. I checked the
sanity-template
repo... Well - not all the commands there work for me, but I opened an issue in that regards over at github.
Sep 24, 2021, 7:15 PM
However this does not solve my issue of creating a new sanity project from the cli
Sep 24, 2021, 7:15 PM
In other words: in my agency we have created a sanity/gatsby boilerplate. I'm currently trying to move this to a sanity template. My ultimate goal would be to replicate the functionality of sanity.io/create for our own starter but from the cli. So any employee could start a new project with a configuration and a simple command
Sep 24, 2021, 7:17 PM
In other words: in my agency we have created a sanity/gatsby boilerplate. I'm currently trying to move this to a sanity template. My ultimate goal would be to replicate the functionality of sanity.io/create for our own starter but from the cli. So any employee could start a new project with a configuration and a simple command
Sep 24, 2021, 7:17 PM
I'd suggest setting up a github repo of the studio for your team to clone, then initializing a new project there if you're looking to bypass using sanity.io/create .
Sep 24, 2021, 7:25 PM
I don't necessarily need to bypass sanity.io/create however how can I use it with my own custom template?
Sep 24, 2021, 7:26 PM
and how would I be creating a new project from a github repo?
Sep 24, 2021, 7:26 PM
thanks!
Sep 24, 2021, 7:26 PM
Actually, reading through this guide, you can create a reusable 1-click template without having to publicly share it on /create! I was wrong! If you follow the steps there, you'll end up with a link that you can share with your team. The drawbacks here: you would have to create on the project in the browser via that link, then, once the project has been created, you would need to
git clone
the repo it gives you. You wouldn't be able to just run a command via the CLI, unfortunately. Sorry for the confusion there πŸ˜…
Sep 24, 2021, 7:47 PM
Thanks rachael, that sounds like precisely what I was looking for! Will look into it
Sep 27, 2021, 7:26 AM

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?