Facebook 无法识别 Netlify 上的一些 Gatsby React Helmet 元标签

标签 facebook gatsby netlify react-helmet

我的一些(但不是全部)Gatsby React Helmet 元标签似乎被 facebook 丢失了。这是代码:

    <Helmet>
      <title>Code Championship | Code is Sport</title>
      <meta name="description" content="Code is Sport. Competitive coding competitions for elementary, middle, and high school students." />
      <meta name="keywords" content="code, championship, competition, minnesota" />
      <meta property="og:url" content="https://www.codechampionship.com" />
      <meta property="og:title" content="Code Championship | Code is Sport" />
      <meta property="og:description" content="Code is Sport. Competitive coding competitions for elementary, middle, and high school students." />
      <meta property="og:type" content="website" />
      <meta property="fb:app_id" content="281289809224344" />
      <meta property="og:image" content="https://www.codechampionship.com/static/running-with-tagline-b034f5627c117830a13bb19345ebb2b0.png" />
      <meta property="og:image:width" content="1080" />
      <meta property="og:image:height" content="608" />
      <meta property="og:image:alt" content="Running Athlete with Code in Foreground" />
      <meta name="twitter:card" content="summary" />
      <meta name="twitter:site" content="@codechampionshp" />
      <meta name="twitter:title" content="Code Championship | Code is Sport" />
      <meta name="twitter:description" content="Code is Sport. Competitive coding competitions for elementary, middle, and high school students." />
      <meta name="twitter:image" content="https://www.codechampionship.com/static/running-with-tagline-b034f5627c117830a13bb19345ebb2b0.png" />
      <link rel="icon" href={logo} />
      <html lang="en" />
      <script id="stripe-js" src="https://js.stripe.com/v3/" async />
    </Helmet>

这是 Facebook 所说的它看到的内容:

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="generator" content="Gatsby 2.0.66" />
<meta name="theme-color" content="#ffe83d" />
<meta data-react-helmet="true" name="description" content="Code is Sport. Competitive coding competitions for elementary, middle, and high school students." />
<meta data-react-helmet="true" name="keywords" content="code, championship, competition, minnesota" />
<meta data-react-helmet="true" property="og:title" content="Code Championship | Code is Sport" />
<meta data-react-helmet="true" property="og:description" content="Code is Sport. Competitive coding competitions for elementary, middle, and high school students." />
<meta data-react-helmet="true" property="og:image" content="/static/running-with-tagline-b034f5627c117830a13bb19345ebb2b0.png" />
<meta data-react-helmet="true" property="og:image:width" content="1080" />
<meta data-react-helmet="true" property="og:image:height" content="608" />
<meta data-react-helmet="true" name="twitter:card" content="summary" />
<meta data-react-helmet="true" name="twitter:site" content="@codechampionshp" />
<meta data-react-helmet="true" name="twitter:title" content="Code Championship | Code is Sport" />
<meta data-react-helmet="true" name="twitter:description" content="Code is Sport. Competitive coding competitions for elementary, middle, and high school students." />
<meta data-react-helmet="true" name="twitter:image" content="/static/running-with-tagline-b034f5627c117830a13bb19345ebb2b0.png" />

Facebook 列出的第一个问题是:

提供的 og:image URL,/static/running-with-tagline-b034f5627c117830a13bb19345ebb2b0.png 不是有效的 URL。

我知道这是因为它需要一个完整的 URL,例如 "https://www.codechampionship.com/static/running-with-tagline-b034f5627c117830a13bb19345ebb2b0.png",但这就是我我在元标记中提供。还有什么我需要做的吗?此错误不会显示在具有完全不同 url 的 Netlify“预览”站点上。因此,这些图像似乎更适合“预览”网站。

Facebook 列出的第二期是:

缺少以下必需属性:og:url、og:type、fb:app_id

这是有道理的,因为它似乎并没有抓取这些。我的元标记中有什么地方做错了吗?

我知道这与其他问题类似,所以我试图阐明这不同之处并列出具体细节。我正在使用 Netlify 进行部署也可能是相关的。

最佳答案

这最终成为一个缓存问题。我没有对代码做任何更改,睡着了,醒来,它开始工作了。我不确定是 Netlify 还是 Facebook 或其他公司在进行缓存。

有人向我建议我可以在最后使用查询字符串来测试(缓存中断)。如果您遇到类似的问题,您可以尝试类似的操作:www.example.com?foo=bar 以强制它进行搜索。它在技术上是不同的 url,但查询字符串不应影响页面结果(除非您使用查询字符串来实现功能)。

关于Facebook 无法识别 Netlify 上的一些 Gatsby React Helmet 元标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53991920/

相关文章:

android - Facebook 从我的 android 应用程序上传对话框

javascript - 如何在 GatsbyJS 节点中添加自定义 GraphQL 参数?

gatsby - 如何处理 `gatsby js` 项目中的文件上传?

javascript - Gatsby 和 Netlify CMS 预览渲染 StaticQuery 时出现错误

webpack-dev-server - 如何使用 Gatsby 和自定义 Webpack 配置进行代理 (netlify-lambda)

netlify - 如何为 Netlify 子域支持构建 repo?

Facebook Graph API 获取所有评论

在提交审核之前测试应用程序的 Facebook 登录权限?

javascript - Facebook Facebook 页面插件无法在网页中运行

node.js - 无法使用 Gatsby 和 Typescript 从 gatsby-config.js 文件中读取 siteMetadata 对象