Setting up a staging site with Netlify

Posted in Development and Serverless

Netlify Deploy Previews are great, but sometimes it’s good to have a way to demo ideas to a client, show your remote team some changes or get approval or feedback from a stakeholder before raising a pull/merge request.

Since moving my website to Netlify, setting up a staging site is something I was putting off – it looked fiddly and it wasn’t super explicit in Netlify’s documentation. Happily, it turned out to be pretty straightforward, once I took a few leaps of faith, and to save you the same uncertainty here’s how to do it.

Note: I’m going to do this for a branch called staging, but you can use whatever subdomain you like, as long as the branch name matches the subdomain. So if your site is, you could set up a subdomain if the branch you want to deploy is named bananas.

Create a staging branch if you don’t already have one

In your local Git repo, use something like git checkout -b staging to create and checkout a staging branch, if you don’t have one already. Then push it to your remote with something along the lines of git push -u origin staging (which also sets creates a link between the two branches, local and remote, with the -u flag – you’re probably going to be using this branch a fair bit so git push and git pull without specifying a remote will be useful!).

Set up Branch deploys for your staging branch

Now that we’ve got a staging branch to deploy from, we need to enable ‘Branch deploys’ in Netlify:

  1. Go to Settings → Build & deploy → Continuous Deployment → Deploy contexts
  2. Hit the ‘Edit settings’ button
  3. Change ‘Branch deploys’ from ‘None’ to ‘Let me add individual branches’
  4. Type ‘staging’ into the ‘Additional branches’ box and press return to change the text into a token
  5. Hit ‘Save’

Add a subdomain to map to the staging deploy

Lastly, we need to add a subdomain to map to the staging branch; this involves a bit of Netlify configuration and adding a DNS record:

  1. Go to Settings → Domain Management → Continuous deployment → Deploy
  2. Enter the subdomain you wish to map staging to (
  3. Now go to your domain name’s DNS control panel and add an A record with staging in the ‘Host’ box (to set the subdomain) and map that to the same IP address you used for your site itself (if in doubt, check the *, www and @/blank A records)
  4. Back in Netlify, check your SSL certificates in Settings → Domain Management → HTTPS and you should see in the list of Domains

Now whenever we push the staging branch to our remote, it’ll deploy to your staging subdomain in the same way that your website itself does!

Follow along

If you enjoyed this post and want to know when the next one is published, head to Twitter and hit ‘Follow’.


More posts

Here are a couple more posts for you to enjoy. If that's not enough, have a look at the full list.

  1. Why I always raise a pull request on solo projects

    The whole point of a PR is to get feedback and approval on a piece of work from someone else before it’s published. But what if it’s just you?

  2. De-prioritising design

    When a friend asked for some CSS tips for a website he works on, I noticed a design issue that actually highlights a common problem in our industry.