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-cli
gatsby new {site-directory} https://github.com/gatsbyjs/gatsby-starter-blog
cd {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 develop
I 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.git
cd {username}.github.io
git checkout -b build
git add . && git commit
touch static/.nojekyll
npm 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