How to Deploy your Static Site to Netlify
Tags: webdev, beginners, netlify, html
Published: 2023-03-13 21:24:59

There are various ways to deploy and host static sites after you design them on your local machine. A static site is a website built with plain HTML, Javascript, or CSS code.**
[Netlify](https://www.netlify.com) is an easy way to deploy and host static web projects without buying a domain name and hosting. Netlify does everything for you.

## Getting Started
In this article, you will learn how simple it is to launch your static site on Netlify. You need an account to deploy on [Netlify](https://www.netlify.com). You will deploy a static site designed with HTML/CSS; check out the [Netlify documentation](https://docs.netlify.com/integrations/frameworks/#create-react-app) to integrate other frameworks like React.js/Next.js.

## Prerequisites
To follow the instructions in each section, you'll need the following setup:
* A code editor such as [VScode](https://code.visualstudio.com/download).
* [Git](https://git-scm.com/downloads) is installed on your system.
* An account with a Git provider ([GitHub](https://github.com/)/[Bitbucket](https://www.atlassian.com/software/bitbucket)/[Gitlab](https://about.gitlab.com/)). GitHub will be used in this article.
* Ensure [Node.js](https://nodejs.org/en/) is installed. To check if Node and npm are installed, type this code in your terminal:
```
node -v //press enter
//v16.13.1
npm -v //press enter
//8.3.0
```

## Deploy to Netlify using Github
To create a repository on GitHub, open a terminal in VScode, run each command line by line, and press enter. A git provider like Github connects your project to enable Netlify to allow [continuous deployment](https://docs.netlify.com/site-deploys/create-deploys/); anytime you make changes to your project and push to GitHub, Netlify automatically redeploys your site, and the changes you make are visible.

```
echo "# My app" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/{your_username}/{your_repository_name}.git
git push -u origin main
```
Check your repository on GitHub, and you should have something like [this](https://github.com/amiabl-programr/test-deploy-to-netlify).
![Github repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ejm8kc9lv398mzfx4wim.png)

Create an account on Netlify and log in to your Netlify dashboard.
![Netlify homepage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cm8e8vkxxjuu3ua1smmd.png)

Switch to the Sites tab, click the Add New Site dropdown, and connect to your GitHub repository.
[Connect to Github repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ra66bxhp9mmvq5c84g7.png)

You will be prompted to authorise Netlify to access your GitHub repositories; if you can’t find the search for a specific repository, select Configure the Netlify app on GitHub.
![Pick a repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8mahbm9gfupy2ln7vog.png)

Then, scroll to the bottom of the page and either grant Netlify access to all your repositories or select a particular repository.
![Select a repository on Github](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/klgnvql2cz927fvzyy1k.png)

Finally, select the repository and click deploy.
![Deploy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32pe784e26y9evskb80v.png)

Your browser will then redirect you to the site overview page, where you can look for the deployment in the list of production deploys. Select the link to open your deployed site.
[Site overview page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/48hwglzvrnlhk9yp495m.png)


## Deploy to Netlify using Drag and Drop
Login to your Netlify Dashboard, switch to the Sites tab, and click the Add New Site dropdown. Select Deploy manually or browse to upload.
![Netlify Drag and Drop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kzaxeucvngjxwsov2zi.png)

Drag and drop your project folder and wait for it to be published.

## Conclusion
In this tutorial, you learned how to use Netlify to deploy your project (HTML or CSS) online using Github and manual deployments.
You can connect a [custom domain name](https://docs.netlify.com/domains-https/custom-domains/) to your site, connect the forms to Netlify for easy management, or check the [documentation ](https://docs.netlify.com/get-started/)to explore more features. 

That’s all for now. Happy Coding!

## Resources
* [Configure environment variables on Netlify](https://docs.netlify.com/environment-variables/overview/).
* [Forms setup](https://docs.netlify.com/forms/setup/).
* [Netlify CLI for Continuous deployment](https://docs.netlify.com/cli/get-started/).
* [Integrate frameworks with Netlify](https://docs.netlify.com/integrations/frameworks/).