As I am preparing for Contentful certification I have been trying to go more heavily through the documentation and run some of their demos. I came across the contentful-cli command contentful guide from a video titled, “A web project in 5-minutes using the Contentful CLI” from the bits and bytes video series. It sounded compelling to me so I dove right in.

First off, the video content is not in line with what the guide produces. Now it produces a blog complete with a content model, some demo content and images, and a complete Gatsby (React) blog, which is fantastic. The only problem is in didn’t work for me. I got several different errors trying to run the command.

First it merged changes into an existing space that I had created as a demo. Effectively ruining that space. Not great.

Then when I ran it again, I got a 404 error on the api when updating space. However, the command it gives works fine when run alone.

So that leaves you with the problem of how to configure the rest. Here is what worked for me:

contentful login
contentful space create --name 'Gatsby Starter Blog'
contentful space seed --template blog --space-id 354m1vhdmt3g
git clone https://github.com/contentful/starter-gatsby-blog.git
cd starter-gatsby-blog
npm install
mv .contentful.json.sample .contentful.json

From there you need to configure the .contentful.json with the space id from above (an example, use the space id you get from the create command). And then you can get the API key by opening your space in the Web App and navigating to the Setting menue, then under Space Settings, choose API Keys. Once this is done you can start the server with npm run dev and otherwise continue to configure to deploy to Netlify or Heroku.

Hope this saves you some time if you are checking out contentful and you get some errors from the contentful-cli as well.