August 27, 2018
I decided to check out GatsbyJS to statically generate my new site, mikeimmersed.com. One reason I chose Gatsby over Jekyll is that I already have npm, but I still haven’t set up Ruby on my current laptop. Also, I figure it might be a good way to get my toes wet with React and GraphQL. Plus, it has several other powerful features that may come in handy later.
Here are the steps I used to get started with Gatsby:
npm install --global gatsby-cligatsby new {site-directory} https://github.com/gatsbyjs/gatsby-starter-blogcd {site-directory}create a new directory in src/pages (or in my case, src/pages/blog)
Example:
---
date: "2018-08-26"
title: "The dolphins have left the building"
---
Where did all the dolphins go?
gatsby developI had a some extra steps for GitHub pages (in addition to GitHub domain configuration and DNS settings):
git clone https://github.com/{username}/{username}.github.io.gitcd {username}.github.iogit checkout -b buildgit add . && git committouch static/.nojekyllnpm install gh-pages --save-dev # if using GitHub pages for hostingadd the following to package.json in scripts:
"deploy": "gatsby build --prefix-paths && gh-pages -b master -d public"npm run deploy
Written by Mike Henry, VR enthusiast and software developer. Follow Mike on Twitter