19 Jan 2018

Why Host Static Sites on Netlify?

I moved a couple of micro websites off my own server and instead started hosting them with Github Pages. Since then another option has presented itself in the form of Netlify. This post is a quick look at Netlify's offering compared to Github Pages and the reasons I'm quickly becoming a fan.

Who are Netlify?

Netlify have been around for a couple of years already, or at least that’s roughly when they hit the front page of HN. They are a start-up trying to offer the ultimate modern hosting solution, where modern means based on static files (e.g. JAMstack). Their service really is a full featured answer to the question of how to host static websites in a scalable and simple way.

As an aside, Netlify being a start-up company is a noteworthy point with regards to selecting a hosting provider. An important feature of hosting is reliability. Beyond the technical side of things, you want the company itself to do well and still be in business in N years time, otherwise you’ll have to migrate your sites and services elsewhere, and likely on someone else’s timeframe. Whilst it’s difficult to tell if Netlify will indeed stand the test of time, they’ve certainly been around for long enough already that using their service doesn’t feel particularly risky.

Let’s Talk Features

Netlify themselves already have a page comparing their offering to Github Pages. The summary is they have a much broader feature set, especially for those that are wanting to host substantial static sites. This makes sense, as Github Pages is certainly more targeted towards repo documentation etc.

Instead of repeating their points, I’ll give a few reasons why I’ve started using Netlify which are maybe less obvious to new users:

Integration beyond GitHub (notably BitBucket)

Perhaps a left over from my student days but I can’t help but gravitate towards a good quality service that has a free tier when it comes to my own personal projects. Github does not provide private repositories for free, so I’ve been a long time user of BitBucket for this purpose. Netlify supports integration from Github, Gitlab or BitBucket. For all three the deployment approach is as you would expect: commit and push, then build and deployment happens automatically for you.

Free and Easy SSL Certificate

To the best of my knowledge it isn’t possible to setup an SSL certificate on Github Pages. At least, not end to end (you could still use a CDN in front of Github and have this terminate the SSL connection).

Netlify on the other hand can provide SSL, and better yet it’s free (using Let’s Encrypt of course). The process to enable this on your Netlify hosted site is very easy. Once you’ve updated your DNS records to point at Netlify you only have to hit an ‘enable SSL’ button from their dashboard and wait for the certificate to be generated and installed. Nothing more to it. They also handle the common cases of redirecting www.foobar.com straight to foobar.com and automatically redirecting users to the HTTPS version of the site. If you’d rather provide your own certificate this is also possible.

Form Data Collection

Netlify allows you to save form responses from your static site. To start with I skimmed over this in the documentation but I’ve come around to believing this could be a killer feature. Looking over my web projects from 2017, I reckon just under half effectively had nothing more than static content with some sort of form attached, whether that’s a landing page designed to capture email addresses or a business site with a contact form for general enquiries. Providing this functionality covers a broad range of basic site requirements in a very convenient way.

Custom Headers and Redirects

You can create a _headers file in your repo for custom HTTP headers. This isn’t just site wide, but supports matching on a specific set of paths.

The file _redirects can also be created in the root of the repo. The file format used supports custom HTTP status codes. That’s useful, as you’re not tied into just 301 Moved Permanently or 302 Found, you can also redirect to a 4xx route or similar. Nifty!

Looking Ahead

So far I’ve only moved a single project to Netlify, but I’ve already got another in mind, one which I’m genuinely looking forward to moving to Netlify - surely a good sign!

I can see static hosting/JAMstack becoming more popular and platforms like Netlify certainly make it easy on the developer. Whilst not offering any technical breakthrough, the execution is well done with a convenience that most web developers already using a git workflow will find very accommodating. Certainly worth a look for anyone using Github Pages for sites beyond documentation.

Dev Git SysAdmin
Back to posts