Skip to content

Latest commit

 

History

History
221 lines (136 loc) · 8.57 KB

InstallationInstructions.md

File metadata and controls

221 lines (136 loc) · 8.57 KB

Installation and Setup Instructions

1st Method

Step 1. Set up the environment

Use the Deploy Button below. It will let you deploy the starter using Vercel as well as connect it to your Sanity Content Lake using the Sanity Vercel Integration.

Deploy with Vercel

Step 2. Set up the project locally

Clone the repository that was created for you on your GitHub account. Once cloned, run the following command from the project's root directory:

npx vercel link

Download the environment variables needed to connect Next.js and the Studio to your Sanity project:

npx vercel env pull

This will create a git-ignored .env file with environment variables that will be used for local development.

Step 3. Run Next.js locally in development mode

npm install && npm run dev

When you run this development server, the changes you make in your frontend and studio configuration will be applied live using hot reloading.

Your blog should be up and running on http://localhost:3000! You can create and edit content on http://localhost:3000/studio.

Step 4. Import Demo Data

  • Import the provided demo data to save time. Execute this command in your terminal:
sanity dataset import production.tar.gz

image

Step 5. Deploy to production

To deploy your changes to production you use git:

git add .
git commit
git push

Alternatively, you can deploy without a git hosting provider using the Vercel CLI:

npx vercel --prod

OR

2ND Method

1. Clone the Repository

git clone https://github.com/SyedaMahamFahim/syedamaham.dev.git

2. Navigate to the Project Directory

cd syedamaham

3. Install Dependencies

npm install

4. Start the Development Server

npm run dev

5. Setting up Sanity

To set up Sanity for your project and get it working with demo data, there is a slightly lengthy process that needs to be followed. Unfortunately, Sanity does not provide the facility to create a project through their website. Please follow the steps below:

6. Renaming the Sanity Folder

  • Firstly, rename the existing Sanity folder to sanity2.
mv sanity sanity2

7. Installing Sanity Globally

  • Install the Sanity CLI globally.
npm install -g @sanity/cli

8. Creating a New Sanity Project

  • After installing the Sanity CLI, create a new Sanity project in the same folder as your project (syedamaham.dev).
sanity init

9. Sanity Configuration

  • Configure your new Sanity project. When prompted, select the options as shown in the screenshot below:

image

10. Two Sanity Projects

  • After completing the setup, you will now have two Sanity projects: sanity and sanity2.

image

11. Project ID

image

12. Copy the Project ID

  • Click on the project to view its details and copy the project ID.

image

13. Deleting the New Sanity Project

  • In your code editor, delete the sanity project folder that you recently created. Be sure to only delete the sanity folder and keep the sanity2 folder intact.

image

14. Renaming the Folder

  • Rename sanity2 back to sanity to avoid copying schemas manually.

15. Creating an Environment File

  • Create an env.local file in your project's root directory to store environment variables or rename the existing env.example to env.local.

image

16. Environment Variables

  • Add the required environment variables to your env.local file. You don't need to search for all of them; you can simply paste the copied project ID. Ignore the other one if you are not planning to use it in a producation

image

17. Creating a Sanity Token

image

18. Token Configuration

  • Name your token and ensure it is set to read-only access.

image

19. Importing Demo Data

  • Import the provided demo data to save time. Execute this command in your terminal:
sanity dataset import production.tar.gz

image

20. Sanity Studio

  • After importing the data, run your website locally and access the Sanity Studio at localhost/studio. Follow any prompts to log in and grant access to localhost.

21. Data

  • Now, you can see data is imported successfully image

22. Working Website

  • Now you will see that the website is now functioning successfully on the local system. image

Following these steps should help you set up your project with Sanity, import demo data, and access it seamlessly. If you have any questions or encounter any issues, please feel free to ask for assistance.