|
| 1 | +# Gatsby Starter Ghost |
| 2 | + |
| 3 | +A starter template to build lightning fast websites with [Ghost](https://ghost.org/) & [Gatsby](https://gatsbyjs.org) |
| 4 | + |
| 5 | +**Demo:** https://gatsby.ghost.org/ |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +# Installing |
| 15 | + |
| 16 | +```bash |
| 17 | +# With Gatsby CLI |
| 18 | +gatsby new gatsby-starter-ghost https://github.com/TryGhost/gatsby-starter-ghost.git |
| 19 | +``` |
| 20 | + |
| 21 | +```bash |
| 22 | +# From Source |
| 23 | +git clone https://github.com/TryGhost/gatsby-starter-ghost.git |
| 24 | +cd gatsby-starter-ghost |
| 25 | +``` |
| 26 | + |
| 27 | +Then install dependencies |
| 28 | + |
| 29 | +```bash |
| 30 | +yarn |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +# Running |
| 36 | + |
| 37 | +Start the development server. You now have a Gatsby site pulling content from headless Ghost. |
| 38 | + |
| 39 | +```bash |
| 40 | +gatsby develop |
| 41 | +``` |
| 42 | + |
| 43 | +By default, the starter will populate content from a default Ghost install located at https://gatsby.ghost.io. |
| 44 | + |
| 45 | +To use your own install, you will need to edit the `.ghost.json` config file with your credentials. Change the `apiUrl` value to the URL of your Ghost site. For Ghost(Pro) customers, this is the Ghost URL ending in `.ghost.io`, and for people using the self-hosted version of Ghost, it's the same URL used to access your site. |
| 46 | + |
| 47 | +Next, update the `contentApiKey` value to a key associated with the Ghost site. A key can be provided by creating an integration within Ghost Admin. Navigate to Integrations and click "Add new integration". Name the integration appropriately and click create. |
| 48 | + |
| 49 | +Finally, configure your desired URL in `siteConfig.js`, so links (e. g. canonical links) are generated correctly. You can also update other default values, such as `postsPerPage` in this file. |
| 50 | + |
| 51 | +To use this starter without issues, your Ghost installation needs to be at least on version `2.10.0`. |
| 52 | + |
| 53 | +The default Ghost version that is used for this starter is `5.x`. If your Ghost installation is on a lower version, you will need to pass in a `version` property in your `.ghost.json` settings: |
| 54 | + |
| 55 | +**Ghost >=2.10.0 <5.0.0** |
| 56 | +```json |
| 57 | +{ |
| 58 | + "apiUrl": "https://gatsby.ghost.io", |
| 59 | + "contentApiKey": "9cc5c67c358edfdd81455149d0", |
| 60 | + "version": "v4.0" |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +**Ghost >=5.0.0** |
| 65 | +```json |
| 66 | +{ |
| 67 | + "apiUrl": "https://gatsby.ghost.io", |
| 68 | + "contentApiKey": "9cc5c67c358edfdd81455149d0" |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +# Deploying with Netlify |
| 75 | + |
| 76 | +The starter contains three config files specifically for deploying with Netlify. A `netlify.toml` file for build settings, a `/static/_headers` file with default security headers set for all routes, and `/static/_redirects` to set Netlify custom domain redirects. |
| 77 | + |
| 78 | +To deploy to your Netlify account, hit the button below. |
| 79 | + |
| 80 | +[](https://app.netlify.com/start/deploy?repository=https://github.com/TryGhost/gatsby-starter-ghost) |
| 81 | + |
| 82 | +Content API Keys are generally not considered to be sensitive information, they exist so that they can be changed in the event of abuse; so most people commit it directly to their `.ghost.json` config file. If you prefer to keep this information out of your repository you can remove this config and set [Netlify ENV variables](https://www.netlify.com/docs/continuous-deployment/#build-environment-variables) for production builds instead. |
| 83 | + |
| 84 | +Once deployed, you can set up a [Ghost + Netlify Integration](https://ghost.org/integrations/netlify/) to use deploy hooks from Ghost to trigger Netlify rebuilds. That way, any time data changes in Ghost, your site will rebuild on Netlify. |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +# Optimising |
| 89 | + |
| 90 | +You can disable the default Ghost Handlebars Theme front-end by enabling the `Make this site private` flag within your Ghost settings. This enables password protection in front of the Ghost install and sets `<meta name="robots" content="noindex" />` so your Gatsby front-end becomes the source of truth for SEO. |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +# Extra options |
| 95 | + |
| 96 | +```bash |
| 97 | +# Run a production build, locally |
| 98 | +gatsby build |
| 99 | + |
| 100 | +# Serve a production build, locally |
| 101 | +gatsby serve |
| 102 | +``` |
| 103 | + |
| 104 | +Gatsby `develop` uses the `development` config in `.ghost.json` - while Gatsby `build` uses the `production` config. |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +# Copyright & License |
| 109 | + |
| 110 | +Copyright (c) 2013-2022 Ghost Foundation - Released under the [MIT license](LICENSE). |
0 commit comments