Continuous deployment with Gatsby and Netlify

In a previous article, I've been talking about Gatsby, and how I have switched to it from my old Jekyll site. As a React developer, this is night and day, and developing / maintaining this site is now a breeze !

However, I also started to reconsider the Github Pages option. I've seen lots of people praise Netlify (and Contentful) without really understanding why, as Github does the job for simple sites really. Well, I've tried it, and let me tell you, no Github Pages for me anymore ! In fact, this is now running on Netlify. Here are a few reasons that made me choose it.

Continous deployment on push

That's right, you can directly deploy from your git repository on pull, a.k.a a continuous development dream come true. No Jenkins pipeline, no Kubernetes, no containers. We're talking static sites here, so it doesn't get any simpler : Just tell Netlify the script your site should run before deployment (gatsby build in my case) and what's the public folder and, voilĂ  ! Now you just commit, push, and your content is live.

No more source branch

That's something that I really hated on a repo point on view : Your build has to be on branch master for Github Pages(in case it is your portfolio, gh-pages otherwise) to use it. Which means that if you want to have the full project (the source) also pushed, you're out of luck, you'll have to create a source branch and think about maintaining it. It doesn't make sense IMO, especially the fact that Gatsby deploy commits will just be something in the lines of "New content". Meh.

Here, you have the full project on you repo, and because Netlify know what's the output folder, there is no need for a dist branch anymore ! The fact that you specify your pre-deploy build command also makes it compatible with every static side generator existing and in the future.

Deploy previews

This is pretty amazing, it allows you to have a separate URL to preview changes before they are deployed on production.

Still not in ?

There are more things that make it a way better choice, such as having a proper WebApp to manage your sites, being able to do more builds on the free plan, pre-rendering.. just head here for the full comparison.

For sure, I'll be deploying my next projects to Netlify, depending on if they are static or not of course.