Understanding CMS using Sanity
Tags: webdev, beginners, programming, tutorial
Published: 2022-01-29 15:17:50

Suppose you are a developer and you want to create a blogging site like DEV, Medium or a social media site like Facebook, Instagram then the most challenging part you are going to face is how are you going to code the post part where users publish the post/article. Here comes the CMS to rescue. In this blog, we will discover what a CMS is, why was it made, what is a headless CMS, examples of CMS including a simple demo on how you can use a CMS using Sanity. 
![cms](https://media.giphy.com/media/xT0xehxwagcgaqpNf2/giphy.gif)

# What is CMS and why it was made? 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6aew2d60b99ueftug7fa.jpg)
In the early days of Web Development, developers faced a lot of issues in managing content which gave the rise of building CMS. CMS refers to <b>Content Management System</b>. It is a tool that is used to manage content which contains editing, creating, and publishing content from various authorized users. In simple words, CMS is a tool that is used to create a website without having extreme knowledge of programming, or even if you don't know programming you are good to go with CMS. Content of CMS is stored in a database. Using a CMS is very user-friendly, allows multiple users to manage the content, improves site maintenance, and much more. 

# How CMS is made? 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t5vbg1t1prps9csk0hf2.png)
<h2> CMS is made up of two applications :</h2> 

<h4>1. CMA (Content Management Application)</h4> 
CMA stands for <b>Content Management Application</b>. In simple words, CMA is the frontend of CMS. CMS gives a lot of templates that help in managing and editing the content. 

<h4>2. CDA (Content Delivery Application)</h4>
CDA stands for <b>Content Delivery Application</b>. CDA is the backend of CMS. It helps the content to get stored in the database and also it publishes the content in the platform and helps it to reach the viewers.    
 
# Examples of CMS 
<h2><a href="https://wordpress.com/">WordPress</a></h2> 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4hemvtaef30inw3i3op7.png)
 
WordPress is one of the most popular CMS currently used. You can create a full working website using WordPress. 

<h2><a href="https://www.drupal.org">Drupal</a></h2> 
 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7msg76k3lgtivr1dpcjm.png)
Drupal is an open-source web CMS that is written in PHP. It acts as an open-source backend framework for CMS. 
 
<h2><a href="https://www.sanity.io/">Sanity.io</a></h2> 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fbf1ljq0tazm8dw60fsm.png)
 
Sanity is a <b>headless CMS</b> that is best for users for collaboration of the project. It is a very powerful platform for generating and modifying content. We will use Sanity.io to show the working of CMS later in this blog.
<br> 
✏️<b>Note:</b> _Headless CMS is a backend-only CMS where content is accessible through APIs._ 
<br>
<h2><a href="https://strapi.io/">Strapi</a></h2> 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okm8x0ddpoxn4c2u2l3d.jpg)
 
Strapi is a headless CMS that is based on node.js. It's highly customizable and self-hosted. 
<h2><a href="https://strapi.io/">GraphCMS</a></h2>
 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4e9gdhpy9zegte0tlus.jpg)
 
GraphCMS is a headless CMS this is based on GraphQL API. It's highly lightweight and it provides a lot of extensions for customizing the UI (User Interface).    
<br>
_There are many more CMSs available the once mentioned above are some popular ones._  
<br>

# Using CMS through Sanity.io  

In this section, we will show the simple working and setting up of CMS using Sanity.io. Sanity provides a lot of templates to demonstrate its system and workings. We will learn how to use Sanity.io CMS through following steps: 

<b>1.</b> Open <a href="https://www.sanity.io/">Sanity.io</a> and click on get started. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lfmm7ifsvzhsba8stz8m.jpg) 
<br>
<b>2.</b> There are two ways to use Sanity, you can create a new project from start and start customizing it using Sanity or you can use the templates provided by Sanity to just explore it and customize it according to your wish. I will be using templates to just show the working of Sanity. There are a lot of templates provided by Sanity. You can choose any templates of your wish. I will be using Next.js Landing Pages template. So click on the “Next.js Landing Pages” section. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jvwrxs14c8xmfjvqiran.jpg)
<br>
<b>3.</b> After clicking on the “Next.js Landing Pages” section, a new page with all the next steps for the deployment of projects appears. First, you have to authenticate to use Sanity. There are three ways you can authenticate to Sanity, I will recommend you to authenticate it through GitHub as it will help you in the next step. You can revoke Sanity access anytime from GitHub. I have authenticated using Google.  

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iqi0hfps8nkikhf2xi25.jpg)
<br>
<b>4.</b> After authentication you have to authorize Sanity to access your GitHub access. After giving the access, Sanity will create a repository in your GitHub account, and it's your choice to keep the repository public or private.      

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6d7ofbalhhmnidipcz1.png)  

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uaxk0sss2slnp7pjqk8l.png)
<br>
<b>5.</b> After the repository is created we have to give Netlify access to sanity as they will use Netlify for deploying the website. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/67hmgx4t34atsy5ogzf3.jpg) 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sqow3htdk7akhqah2rxt.png) 
<br>
<b>6.</b> After completing all the steps mentioned above, the project is ready to use. Open Sanity Studio and open the website. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fnch4ztik63xfotoeaj.png) 
<br>
<b>7.</b> First we will see the website we just deployed. I will be changing the section marked with a blue lining. I will be changing the background image and text. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/niw2zimq7fl380g2z17l.jpg) 
<br>
<b>8.</b> Open Sanity Studio. You need to authenticate before using Sanity Studio.In simple words, Sanity Studio is a tool through which we can easily edit the content of the website and do a lot of things. Open pages and click on Frontend.   

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1j8jpwl51m5mcrztrs8.png) 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3h78lb8l9pd8wtxi301z.jpg) 
<br>
<b>9.</b> A sidebar appears where you can edit the different parts of the website and content as per your wish. After making changes click on publish. Wait for approx. 2 to 5 minutes to get the website updated. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qkgkhpfqxu65q55kyawa.jpg) 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32fhmtk3lrdc619b1yjy.png) 
<br>
<b>10.</b> Visit the website and you can see the changes are implemented.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wv49regru6pzn93ijmyv.png) 
<br> 
Hurray 🥳, we just used the Sanity CMS to change the content of our website 🎉. 
<br>
The main purpose behind this blog was to explain what a CMS is as I was also not knowing about CMS previously and this blog is my research about it as I am going to use CMS in my future projects. At last, I would like to thank you for taking the time for reading this blog. Please comment and do express your views about this blog. If you have any queries, feedback regarding this blog feels free to comment and contact me on Twitter(<a href="https://twitter.com/HarshitAditya1">@HarshitAditya1</a>). I am highly active on Twitter and I would happy to solve your queries and have a conversation with you. 
![cms](https://media.giphy.com/media/ABhl0oGBxJ8Z7gAuYo/giphy.gif)