
Gatsby Starter Ghost
One of the best ways to start a new Gatsby site is with a Gatsby Starter, and in this case, it’s no different.Prerequisites
To use Gatsby Starters, and indeed Gatsby itself, the Gatsby CLI tool is required. Additionally, a Ghost account is needed to source content and get site related credentials.Getting started
To begin, generate a new project using the Gatsby Starter Ghost template with the following CLI command:http://localhost:8000/
in a browser and view the newly created Gatsby site.

Making it your own
So, you’ve set up a Gatsby site, but it’s not showing the right content. This is where content sourcing comes into play. Gatsby uses GraphQL as a method of pulling content from a number of APIs, including Ghost. Sourcing content from Ghost in the Gatsby Starter Ghost template is made possible with the Gatsby Source Ghost plugin. Configuring the plugin can be done within the template files. Within the project, navigate to and open the file named.ghost.json
, which is found at root level:
netlify.toml
file that comes with the starter template provides the deployment configuration straight out of the box.
Next steps
The official Gatsby docs is a great place to learn more about how typical Gatsby projects are structured and how it can be extended. Gaining a greater understanding of how data and content can be sourced from the Ghost API with GraphQL will help with extending aforementioned starter project for more specific use cases. There’s also a guide for setting up a new static site, such as Gatsby, with the hosting platform Netlify. For community led support about linking and building a Ghost site with Gatsby, visit the forum. As with all content sources for Gatsby, content is fed in by GraphQL, and it’s no different with Ghost. The official Gatsby Source Ghost plugin allows you to pull content from your existing Ghost site.Getting started
Installing the plugin is the same as any other Gatsby plugin. Use your CLI tool of choice to navigate to your Gatsby project and a package manager to install it:.ghost.io
, for example: mysite.ghost.io
. For self-hosted versions of Ghost, use the admin panel access URL and ensure that the self-hosted version is served over a https connection. The Content API Key can be found on the Integrations screen of the Ghost Admin.
Open the gatsby-config.js
file and add the following to the plugins
section:
Querying Graph with GraphQL
The Ghost API provides 5 types of nodes:- Post
- Page
- Author
- Tag
- Settings
Next steps
GraphQL is a very powerful tool to query the Ghost API with. This is why we’ve documented a few recipes that will get you started. To learn more about the plugin itself, check out the documentation within the repo on GitHub. There’s also plenty of documentation on what the Ghost API has to offer when making queries. To learn more about GraphQL as a language, head over to the official GraphQL docs.Use-cases
There are many additional aspects to switching from a typical Ghost front-end to a standalone API driven front-end like Gatsby. The following sections explain some slightly ‘grey area’ topics that have been commonly asked or may be of use when making this transition.Switching over
Switching to a new front-end means handling the old front-end in a different way. One option is to make the old pages canonical, meaning that these pages will remain online, but will reference the new counterparts on the API driven site. Check out the documentation on using canonical URLs in Ghost.
Generating a sitemap
Providing a well made sitemap for search indexing bots is one of the most important aspects of good SEO. However, creating and maintaining a series of complex ‘for loops’ can be a costly exercise.