Using Ghost as a headless CMS
In a previous post I described how I investigated hosting ghost for free using Heroku and how this will allow me to potentially pull data from Ghost and build it into a static site which I can also get hosted for free (or at least a lot cheaper than what I am currently paying). I did spend some time investigating various site scrapers that would pull the ghost content directly and build a static site and though I could get these (mostly) working locally I couldn't find anyway to run them simply/cheaply in the cloud so that I could automate the process and make the effort of getting the scraper work properly worth it.
Ghost however refers to itself as a headless CMS and so I thought that I'll look into what the community is doing in this space and this is how I came across Gatsby and the deployment/hosting platform called Netlify, as I had a few false starts I'll describe how I got it to work.
Installing and running Gatsby
First download the Gatsby CLI tool using npm and then prepare the starter project that is pre-configured to pull data from Ghost via its API.
npm install -g gatsby-cli gatsby new gatsby-blog-ghost https://github.com/TryGhost/gatsby-starter-ghost
This will create a folder called
gatsby-blog-ghost and inside it will be, after a little configuration, all that is needed to build a static site from the Ghost platfrom.
- From the Ghost admin portal create a custom integration
- Update the production entry in `.ghost.json` (found in the
gatsby-blog-ghostfolder) with the supplied API key and API URL
- Test the settings work by and navigating to the supplied URL e.g. http://localhost:9000
gatsby build gatsby serve
Work in progress...
Your feedback is appreciated