2
votes

I'm using Ghost with gatsby-starter-ghost and running into an issue with the generated sitemap.xml from gatsby-plugin-advanced-sitemap as well as the RSS feed URL.

My domain name is https://www.officehomelife.com/ and is hosted on https://officehomelife.netlify.app/

The problem is https://www.officehomelife.com/sitemap.xml is generating URLs based off of the netlify domain name and not my domain name. It is also using the netlify domain name for the RSS feed https://feedly.com/i/subscription/feed/https://officehomelife.netlify.app/rss/

I believe this value should be coming from gatsby-starter-ghost\src\utils\siteConfig.js where I have it defined:

    siteUrl: `https://www.officehomelife.com`, // Site domain. Do not include a trailing slash!

    postsPerPage: 12, // Number of posts shown on paginated pages (changes this requires sometimes to delete the cache)

    siteTitleMeta: `Office Home Life`, // This allows an alternative site title for meta data for pages.
    siteDescriptionMeta: `The essential guide to working from home`, // This allows an alternative site description for meta data for pages.

    shareImageWidth: 1000, // Change to the width of your default share image
    shareImageHeight: 523, // Change to the height of your default share image

    shortTitle: `Office`, // Used for App manifest e.g. Mobile Home Screen
    siteIcon: `favicon.png`, // Logo in /static dir used for SEO, RSS, and App manifest
    backgroundColor: `#e9e9e9`, // Used for Offline Manifest
    themeColor: `#15171A`, // Used for Offline Manifest
}

I tried deleting a .cache folder but that did not help, any other ideas?

Thanks

1
Can you provide the configuration for the gatsby-plugin-advanced-sitemap?Ferran Buireu
I've added the full siteConfig which the sitemap plugin uses.KevinUK
I've noticed I don't get this issue on my local Gatsby build so it's something to do with Netlify. I've tried adding an environment variable SITEURL officehomelife.com I'll ask on their forums. The sitemap plugin code has siteMetadata: { siteUrl: process.env.SITEURL || config.siteUrl, },KevinUK

1 Answers

2
votes

Dealing with environment variables it's a little bit tricky, you have to prefix the variables with GATSBY_ to make them available to the server (Netlify) in the browser-side:

In addition to these Project Environment Variables defined in .env.* files, you could also define OS Env Vars. OS Env Vars which are prefixed with GATSBY_ will become available in browser JavaScript.

So, your process.env.SITEURL should become:

siteMetadata: { siteUrl: process.env.GATSBY_SITEURL || config.siteUrl, }

And so on for the rest of the environment variables.