Deployment
uDocs uses sanity cms for content management and it integrates with algolia to provide exceptional search experience. uDocs utilizes vercel incremental static regeneration (ISR) feature to create or update content on uDocs without redeploying. So to deploy uDocs you need to create sanity cms, algolia and vercel accounts. Following is the step by step guide how to integrate all thses services to create uDocs deployment.
Sanity CMS
You first need to create sanity cms account if you don't have one. After creating sanity cms account you need to create project init and collect following ENV variable that would be used while deploying uDocs to the vercel. These ENV are
NEXT_PUBLIC_SANITY_DATASET
NEXT_PUBLIC_SANITY_PROJECT_ID
SANITY_API_READ_TOKEN
SANITY_WEBHOOK_SECRET
Following tutorial shows you how to collect those variables from Sanity CMS.
Algolia Search
uDocs integrates with Algolia to provide your customers with world class search experience. To integrate algolia with uDocs you first need to create algolia account if you don't have any yet. After creating Algolia account you need to create algolia application and create index inside it. This index will contain all of your algolia records. You need to collect following ENV variables values from algolia.
NEXT_PUBLIC_ALGOLIA_INDEX
NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_API_KEY
NEXT_PUBLIC_ALGOLIA_APPLICATION_ID
ALGOLIA_ADMIN_API_KEY
Following tutorial shows you how to collect those variables from Algolia.
Vercel Deployment
Now you have created your Sanity and Aloglia accounts and have collected all the ENV variables that are needed for uDoc deployment. Now you can click following deploy button which will take you to vercel where you will fork uDocs public repo and add values of all ENV variables and deploy your uDocs website.
After deploying website, vercel will provide you with domain which you can use to access your website. Now you have completed deployment of your website and any new commit to your main branch will trigger build in vercel and it will rebuilt your website and deploy it.
To access studio from that domain you need to add that domain into sanity CORS so that you can access studio with that domain. You have to create v1
and create and doc with introduction
slug in sanity studio to see doc page.
Now you have to create webhooks in Sanity CMS for updating your algolia records so that whenever there is change in your docs it gets reflected in algolia search. You will also have to create revalidation webhooks as well to tell vercel that your content is changed so that it can update your website. Next article details how to create these webhooks.