05-March-2019

Hosting a Gatsby Site on Zeit Now


"I recently launched my website, and with that comes hosting. I was originally going to go with Netlify for my hosting but ended up with Zeit's Now service. "

I bought my domain tomwritesco.de from Zeit's new domain service. The thing I didn't look into when purchasing was if I could chage the name server which would allow me to host my site on Netlify and take advantge of their auto rebuild and web-hooks that would trigger a rebuild when I updated Contentful.

Hosting the site on Zeit's Now was really easy, I only had to do a little bit of research in what was needed to get a Gatsby project going. The main part was putting a now.json file into the root of the project.

Inside of the now.json file just needs to have the following.

{
  "version": 2,
  "name": "Your Project Name",
  "build": [
    { 
      "src": "package.json",
      "use": "@now/static-build",
      "config": {"distDir": "public"} 
    }
  ]
}

This file just lets Now know what to do with the files it is receiving. "version" is setting what verion of Now will be used (In this case version 2). "name" is what name will show up in your Zeit Dashboard. "build" is the main command that will set off the build of the Gatsby site and directs Now to the public folder which is build when Gatsby generates the static pages.

 
<tomWritesCode />