Gatsby sitemap.xml 和 rss feed 使用了错误的域名

Gatsby sitemap.xml and rss feed using wrong domain name

我将 Ghost 与 gatsby-starter-ghost 和 运行 一起使用,发现 gatsby-plugin-advanced-sitemap 生成的 sitemap.xml 以及 RSS 提要 [=28] =].

我的域名是https://www.officehomelife.com/ and is hosted on https://officehomelife.netlify.app/

问题是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/

我相信这个值应该来自 gatsby-starter-ghost\src\utils\siteConfig.js 我定义它的地方:

    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
}

我尝试删除 .cache 文件夹但没有帮助,还有其他想法吗?

谢谢

Dealing with environment variables 这有点棘手,您必须在变量前加上 GATSBY_ 前缀,以使它们可用于 browser-side:[=17= 中的服务器 (Netlify) ]

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.

所以,你的 process.env.SITEURL 应该变成:

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

其余环境变量依此类推。