Get fast up and running with a blog boilerplate using static page generator using Gatsby (a blazing-fast static site generator for React) and a CMS with Contentful hosted by Netlify.
This project is based on the contentful-starter project. Read more about it here: https://github.com/contentful-userland/about.
-
Contentful account, get one for free here: https://www.contentful.com/sign-up/.
-
Netlify account, get one for free here: https://app.netlify.com/signup.
- First make sure you have npm installed on your machine
-
Windows check here: http://blog.teamtreehouse.com/install-node-js-npm-windows
-
Mac: a) Install Homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
b) Install npm brew install node
-
Linux: Run this command in the terminal (Ctrl + Alt + T) sudo apt update && sudo apt install nodejs
-
Install the Gatsby CLI npm install --global gatsby-cli
-
Create a new Gatsby project using this github rep: gatsby new gatsby-blog-boilerplate https://github.com/josefnorlin/gatsby-blog-boilerplate
-
Open the folder: cd gatsby-blog-boilerplate
-
Install it: npm install
-
Run the setup: npm run setup -- --spaceId tyz8w5nhoib9 --deliveryToken [get-from-contentful] --managementToken [get-from-contentful]
RUN LOCALLY:
-
Go to your folder (cd [folder location])
-
(only the first time) npm run setup
-
Run: npm run dev
DEPLOY:
- (only the first time) First make sure you've installed netlifyctl by running:
-
Windows:
- Install scoop: Make sure Powershell 3 (or later) and .NET Framework 4.5 (or later) are installed. Then run:
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
-
Use scoop to add netlifyctl as a bucket: scoop bucket add netlifyctl https://github.com/netlify/scoop-netlifyctl
-
Then install it by: scoop install netlifyctl
-
Mac:
-
Add netlify tap to brew: brew tap netlify/netlifyctl
-
Install it running: brew install netlifyctl
-
-
Linux: Follow the instructions here: https://github.com/netlify/netlifyctl
-
(only the first time) Go to your folder (cd [folder location])
-
(only the first time) Login to: netlifyctl login
-
Build the website by running: npm run build
-
Deploy it: npm run build && netlifyctl deploy -b public
This project comes with a Contentful setup command npm run setup
.
This command will ask you for a space ID, and access tokens for the Contentful Management and Delivery API and then import the needed content model into the space you define and write a config file (./contentful.json
).
npm run setup
automates that for you but if you want to do it yourself rename .contentful.json.sample
to .contentful.json
and add your configuration in this file.
Removes all dependencies, scripts and data from the installation script.
- Tutorial video series "Building a blazing fast website with GatsbyJS and Contentful" by @Khaledgarbaya