How to Host Your Website for Free on Netlify (& Keep Your Github Repo Private)
Tags: beginners, webdev, github, tutorial
Published: 2022-11-21 15:52:56

**TLDR: On free Github, you can't host your website on Github Pages AND keep your repository private. You can pay to upgrade Github if you want, but I will show you how you can host it on Netlify instead.**

Recently I built a new personal website which I wanted to publish, but I also wanted to keep the repository private. I use Github to store my code, so usually I would use Github pages to publish my site. However on the free version of Github, you can't publish your site on Github Pages AND keep your repo private; you have to upgrade and pay for that. 

Well I didn't want to pay :smile: but luckily [Netlify](https://www.netlify.com/) is super easy and free!

Set up an account with [Netlify](https://www.netlify.com/) if you don't have one already. Just select the starter option which is free and you can set up a new 'team' to start with. I just set up a team of me :grin:

Once that was all set up, I went ahead and selected "Add new site". 

![Screenshot of Netlify Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/81j9wiiallivfoyo34cx.png)

I went with "Import an existing project":

![Options displayed when you click add new site](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8oec1ehb39ve6z67dpcm.png)

Choose your Git provider (I'm going with Github of course) and it will take your through the process of connecting to your account and then a list of all your repos (even the private ones) will be available for you to choose from.

![Options for connecting to git repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8qouco8gzt0p4nh1otl.png)

Choose the repo of your site that you want to publish and then you'll get to this next screen. If you've kept things simple, then owner should be you and branch to deploy is probably "main". I have never needed to make any changes to the "Basic build Settings" section myself, but you can certainly go and learn more about it.

![screenshot build options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4148tic6ucez7wik1rh3.png)

Click "Deploy site" when you're ready and it will start the build / deploy process. If there are any errors, then they will be highlighted here, otherwise your site will be live! It's that easy!

At this point, if you have a custom domain you've purchased, you can also add it via the "Domain Settings" option. I won't go into that now, but there is some helpful information for that on [Netlify's docs](https://docs.netlify.com/domains-https/custom-domains/#app) and you can also ask your domain provider if you're not sure how to connect it to your site.

There we are! I think that's a pretty straightforward option for even beginners looking to host their first site, but if you have any other recommendations / tips then please do share so everyone can learn! :relaxed:
_
Credit: Cover photo by <a href="https://unsplash.com/@cookiethepom?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Cookie the Pom</a> on <a href="https://unsplash.com/s/photos/dog-laptop?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>_