# Integrating Ghost CMS Theme gatsby-starter-ghost with an existing gatsbyJS project

**URL:** <https://forum.ghost.org/t/integrating-ghost-cms-theme-gatsby-starter-ghost-with-an-existing-gatsbyjs-project/7472>\
**Category:** Installation\
**Created:** [May 24, 2019, 12:44pm UTC](https://forum.ghost.org/t/integrating-ghost-cms-theme-gatsby-starter-ghost-with-an-existing-gatsbyjs-project/7472 "2019-05-24T12:44:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnsrikanth](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jnsrikanth](https://forum.ghost.org/u/jnsrikanth)\
**Post date:** [May 24, 2019, 12:44pm UTC](https://forum.ghost.org/t/integrating-ghost-cms-theme-gatsby-starter-ghost-with-an-existing-gatsbyjs-project/7472/1 "2019-05-24T12:44:57Z")

</div>

I am trying to integrate the gatsby-starter-ghost starter template from Github into my GatsbyJS project which is a simple static website.

I have tried to add the contents of the gatsby-config.js from the gatsby-starter-ghost project to my own gatsbyJS web project which has its own gatsby-config.js.

However I am facing errors while doing a “gatsby develop” in the home directory of my gatsbyJS web project. I have copied the contents of the gatsby-starter-ghost pages (index.js etc.) into a separate folder called “blog” inside my web-app src/pages folder.

- What’s your URL? This is the easiest way for others to debug your issue

- What version of Ghost are you using?  
[GitHub - TryGhost/gatsby-starter-ghost: A starter template to build lightning fast websites with Ghost & Gatsby](https://github.com/TryGhost/gatsby-starter-ghost) - I am using this version of the ghost starter for gatsbyJS

- What configuration?

I am using the below gatsbyconfig.js

const guid = process.env.NETLIFY\_GOOGLE\_ANALYTICS\_ID;  
const path = require(`path`)

const config = require(`./src/utils/siteConfig`)  
const generateRSSFeed = require(`./src/utils/rss/generate-feed`)

let ghostConfig

try {  
ghostConfig = require(`./.ghost`)  
} catch (e) {  
ghostConfig = {  
production: {  
apiUrl: process.env.GHOST\_API\_URL,  
contentApiKey: process.env.GHOST\_CONTENT\_API\_KEY,  
},  
}  
} finally {  
const { apiUrl, contentApiKey } = process.env.NODE\_ENV === `development` ? ghostConfig.development : ghostConfig.production

```
if (!apiUrl || !contentApiKey || contentApiKey.match(/<key>/)) {
    throw new Error(`GHOST_API_URL and GHOST_CONTENT_API_KEY are required to build. Check the README.`) // eslint-disable-line
}

```

}

module.exports = {  
siteMetadata: {  
title: ‘Technovature Software’,  
description: ‘Next Generation Innovation’,  
contact: {  
phone: ‘+91 7013175234’,  
email: ‘info@technovature.com’,  
address: ‘Hyderabad’,  
},  
menuLinks: [  
{  
name: ‘Services’,  
link: ‘/services’,  
},  
{  
name: ‘OUR WORK’,  
link: ‘/work’,  
},  
{  
name: ‘About’,  
link: ‘/about’,  
},  
{  
name: ‘Blog’,  
link: ‘/blog’,  
},  
{  
name: ‘Testimonials’,  
link: ‘/testimonials’,  
},  
{  
name: ‘Contact’,  
link: ‘/contact’,  
},  
],  
},  
plugins: [  
‘gatsby-plugin-sass’,  
‘gatsby-transformer-json’,  
‘gatsby-transformer-remark’,  
‘gatsby-plugin-react-helmet’,  
{  
resolve: ‘gatsby-source-filesystem’,  
options: {  
path: `${__dirname}/src/pages`,  
name: ‘pages’,  
},  
},  
{  
resolve: ‘gatsby-source-filesystem’,  
options: {  
path: `${__dirname}/src/data`,  
name: ‘data’,  
},  
},  
{  
resolve: ‘gatsby-source-filesystem’,  
options: {  
path: `${__dirname}/src/images`,  
name: ‘images’,  
},  
},  
{  
resolve: ‘gatsby-plugin-google-analytics’,  
options: {  
trackingId: guid ? guid : ‘UA-XXX-1’,  
// Puts tracking script in the head instead of the body  
head: false,  
},  
},  
`gatsby-plugin-sharp`,  
`gatsby-transformer-sharp`,  
{  
resolve: `gatsby-source-ghost`,  
options:  
process.env.NODE\_ENV === `development`  
? ghostConfig.development  
: ghostConfig.production,  
},  
/\*\*  
\* Utility Plugins  
\*/  
{  
resolve: `gatsby-plugin-ghost-manifest`,  
options: {  
short\_name: config.shortTitle,  
start\_url: `/`,  
background\_color: config.backgroundColor,  
theme\_color: config.themeColor,  
display: `minimal-ui`,  
icon: `static/${config.siteIcon}`,  
query: ` { allGhostSettings { edges { node { title description } } } } `,  
},  
},  
{  
resolve: `gatsby-plugin-feed`,  
options: {  
query: ` { allGhostSettings { edges { node { title description } } } } `,  
feeds: [  
generateRSSFeed(config),  
],  
},  
},  
{  
resolve: `gatsby-plugin-advanced-sitemap`,  
options: {  
query: ` { allGhostPost { edges { node { id slug updated_at created_at feature_image } } } allGhostPage { edges { node { id slug updated_at created_at feature_image } } } allGhostTag { edges { node { id slug feature_image } } } allGhostAuthor { edges { node { id slug profile_image } } } }`,  
mapping: {  
allGhostPost: {  
sitemap: `posts`,  
},  
allGhostTag: {  
sitemap: `tags`,  
},  
allGhostAuthor: {  
sitemap: `authors`,  
},  
allGhostPage: {  
sitemap: `pages`,  
},  
},  
exclude: [  
`/dev-404-page`,  
`/404`,  
`/404.html`,  
`/offline-plugin-app-shell-fallback`,  
],  
createLinkInHead: true,  
},  
},  
`gatsby-plugin-force-trailing-slashes`,  
`gatsby-plugin-offline`,

],  
};

- What browser?  
Chrome
- What errors or information do you see in the console?  
Upon running a ‘gatsby develop’ command, I see the below errors…

error We encountered an error while trying to load your site’s gatsby-config.  
TypeError: Cannot destructure property `apiUrl` of ‘undefined’ or ‘null’.

- What steps could someone else take to reproduce the issue you’re having?  
gatsby develop command…

---

<div class="post-metadata">

**Author:** ![Aileen](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/aileen/32/9846_2.png) [@Aileen](https://forum.ghost.org/u/Aileen)\
**Post date:** [May 27, 2019, 1:28am UTC](https://forum.ghost.org/t/integrating-ghost-cms-theme-gatsby-starter-ghost-with-an-existing-gatsbyjs-project/7472/2 "2019-05-27T01:28:56Z")

</div>

The config looks ok to me. How are you creating the pages in `gatsby-node.js` tho? You will need to updated the used templates for each source and updated the URL’s for each page that gets created to have `/blog/` prepended.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/ba9ce5100b8bb264586f4f572545596b2ce3f081.png) [@system](https://forum.ghost.org/u/system)\
**Post date:** [June 10, 2019, 1:28am UTC](https://forum.ghost.org/t/integrating-ghost-cms-theme-gatsby-starter-ghost-with-an-existing-gatsbyjs-project/7472/3 "2019-06-10T01:28:57Z")

</div>

Closed on June 10, 2019, 1:28am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
