How to host a Git repository on a subdomain with Netlify

Glyn Lewington
May 23, 2019 · 2 min read

Let’s say you have your portfolio, like, hosted on Netlify and want to add your projects onto the same domain. They are all separate git repositories and Netlify is made for hosting from a single repository…but don’t fear! We can host them on subdomains like with just a little work.

Image for post
Image for post
Photo by Nicole Y-C on Unsplash

Netlify makes it super easy to host your static sites with them for free. I recently moved my portfolio from a VPS over to them, and it’s great that they automatically update your site every time you push to your git repository.

In the past, I had all my personal projects also hosted on subdirectories, e.g. This is either difficult or impossible with Netlify. Netlify is mostly set up for you to host everything in one site from one git repository.

The compromise I came to is hosting them on subdomains instead, like This also isn’t documented very well but it is possible.

  • Go to and login or signup.
  • Select “New site from git”.
  • Choose your provider (e.g. GitHub) — You may need to authenticate here.
  • Select the git repository you want to create a site from.
  • Select the branch you want to deploy from.
  • Choose any commands that need to be run. — If it’s a React app you will need to run a build command.
  • Choose the directory that you will publish from. It will contain files such as index.html. — If it’s a React app this will probably be the build folder.
  • Select “Build Site”.

At this point, you should have a functioning app hosted on a Netlify free domain such as If this isn’t working, check that there are no errors with the build process and fix these if there are.

Now to set up a custom domain.

  • Go into your app overview on Netlify.
  • It will say your site is deployed successfully and you can set up a custom domain.
  • Click on set up a custom domain, type in the domain you want, including the subdomain, and click verify. E.g.

Next, login to your domain hosting provider. I use Cloudflare but it will be the same or similar using others.

  • Go to DNS settings.
  • Select a new CNAME record.
  • Input a “Name” — this is the subdomain, it should be the same one you selected previously on Netlify. E.g. project
  • Under “IPv4 Address” input the free domain for your Netlify site. E.g.
  • If you are also using Cloudflare, turn off the traffic routing through Cloudflare. This messes with Netlify.
  • Add record.

Done! Once you’ve done this you can access your site on the subdomain.

Netlify will also automatically add https security to your site, no need to worry about this.

This is no longer updated.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store