如何解决Gatsby sitemap.xml和rss feed使用错误的域名
我将Ghost与gatsby-starter-ghost一起使用,并且遇到了gatsby-plugin-advanced-sitemap生成的sitemap.xml以及RSS feed URL的问题。
我的域名为https://www.officehomelife.com/,托管在https://officehomelife.netlify.app/
问题是https://www.officehomelife.com/sitemap.xml正在基于netlify域名而不是我的域名生成URL。它还将netlify域名用于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_
才能使它们可用于浏览器端的服务器(Netlify):
除了
.env.*
中定义的这些项目环境变量之外 文件,您还可以定义OS Env Vars。 OS Env Vars是 前缀为GATSBY_
的前缀将在浏览器JavaScript中可用。
因此,您的process.env.SITEURL
应该成为:
siteMetadata: { siteUrl: process.env.GATSBY_SITEURL || config.siteUrl,}
其余的环境变量依此类推。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。