Getting started with Gatsby?


#1

Huge congrats on the latest updates, folks! I remember having a look at your docs when you moved it to gatsby and was immediately in love with how fast it was. Naturally, when I saw the tweet last night, I was excited.

However, as someone who isn’t well equipped with the dev world, I was wondering if there are any beginner’s guide on how to use Gatsby with ghost?

Any pointers will be appreciated. :slight_smile:


#2

Thank you!

The best point for you to start is using the official Gatsby + Ghost starter here: https://github.com/TryGhost/gatsby-starter-ghost

Give this a try and let us know if you get stuck or the information is unclear :hugs:


#3

What about Ghost(Pro) users? How would it be available for them?


#4

The Ghost Docs use Ghost(Pro) as a content source.

This forum topic might give you a bit of background as to how a Gatsby+Ghost integration works:

the tl;dr is your Ghost publication will be set in private mode, and you will use the content API to pull posts from your publication and build your static site. That static site will be hosted somewhere like Netlify


#5

But your explanation sounds like you would just switch to another place to host the content and then let that place serve the site?

So if you write a post then

  1. Netlify webhook takes content through Ghost API
  2. Netlify serves content somewhere?

Or what? But where does Netlify serve that content? And how? How could you make that content be served on the same domain as a site is running before switching to Netlify?

It honestly seems more like a hassle than anything, but I’m open to trying it. I’m just not exactly sure how you would proceed.


#6

That’s right, Ghost is only being used as a content management interface, and is not responsible for the site frontend.

Netlify serves the content from its own servers - your build script will generate files, and Netlify will take those files and serve them just like you would static HTML.

Ghost has the ability to set the host for the admin panel - in the case of Ghost(Pro), you have your .ghost.io domain as well as your dedicated domain (for example, docs.ghost.org) which actually has the frontend

So, to answer your question, unless you use a more advanced server configuration, the admin panel for Ghost will be hosted on a domain different than where your content is hosted

This isn’t really something super necessary - it’s more of Ghost having a larger feature set, rather than something everyone should use. If you have a use case for deploying static sites in this method, go for it, but using Ghost as you have been for the past few years is still a completely normal and functional method for managing your site.


#8

Yep, because you’re going to be pulling in posts from the ghost instance


#10

Your best bet is the starter repo:


#12

It’s really difficult to provide information without being able to see the logs. For example, how do you know Ghost isn’t communicating with Netlify? Are your builds not being triggered? Are you able to configure Gatsby to pull in posts from Ghost using the content API key?


#14

Did you update the content API key in .ghost.json?


#16

You also need to change the apiUrl values to point at your Ghost instance, in your case it would be your Ghost(Pro) subdomain so something like "https://xyz.ghost.io" (replacing xyz with your actual subdomain).


#17

Thank you guys, this is useful info for the rest that want to try Gatsby integration soon!