gpt4 book ai didi

Gatsby sitemap.xml 和 RSS 提要使用错误的域名

转载 作者:行者123 更新时间:2023-12-04 08:41:39 27 4
gpt4 key购买 nike

我将 Ghost 与 gatsby-starter-ghost 一起使用,并遇到了从 gatsby-plugin-advanced-sitemap 生成的 sitemap.xml 以及 RSS 提要 URL 的问题。
我的域名是https://www.officehomelife.com/并托管在 https://officehomelife.netlify.app/
问题是https://www.officehomelife.com/sitemap.xml正在根据 netlify 域名而不是我的域名生成 URL。它还使用 netlify 域名作为 RSS 提要 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_使它们可用于浏览器端的服务器(Netlify):

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


那么,您的 process.env.SITEURL应该变成:
siteMetadata: { siteUrl: process.env.GATSBY_SITEURL || config.siteUrl, }
其余的环境变量依此类推。

关于Gatsby sitemap.xml 和 RSS 提要使用错误的域名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64539561/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com