【问题标题】:Facebook not recognizing some Gatsby React Helmet Meta Tags on NetlifyFacebook 无法识别 Netlify 上的一些 Gatsby React Helmet Meta 标签
【发布时间】:2022-03-08 05:19:05
【问题描述】:

我的 Gatsby React Helmet Meta Tags 中的一些(但不是全部)似乎被 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 列出的第一个问题是:

Provided og:image URL, /static/running-with-tagline-b034f5627c117830a13bb19345ebb2b0.png was not a valid URL.

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

Facebook 列出的第二个问题是:

The following required properties are missing: og:url, og:type, fb:app_id

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

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

【问题讨论】:

    标签: facebook gatsby netlify react-helmet


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      让我链接 Luke 的 GitHub 问题: https://github.com/gatsbyjs/gatsby/issues/10743

      surge.sh 也有同样的问题

      我找到了很好的工具来检查 Facebook 和 Twitter 在抓取 og 标签时真正在做什么: * https://developers.facebook.com/tools/debug/sharing/ * https://cards-dev.twitter.com/validator

      在 Facebook 上,也有 Scrape Again 按钮:

      【讨论】:

      • 谢谢!我确实再次尝试了刮擦。再次抓取仍然没有更新(似乎仍然拉旧版本),所以我不得不使用查询字符串。
      【解决方案3】:

      我最近遇到了同样的问题,发现这是 Netlify 上一个过时的缓存插件问题。通过单击 Netlify 构建中的“清除缓存并部署站点”按钮,我能够进行临时修复。但是对于创建的每个新页面,我们都会看到页面的 SSR 版本中元数据不正确的问题。当我将Essential Gatsby plugin 升级到 v2.1.2 时,我开始在 SSR 页面和页面的浏览器版本上看到正确的元数据。

      【讨论】:

        猜你喜欢
        • 2021-06-14
        • 1970-01-01
        • 2016-01-17
        • 1970-01-01
        • 1970-01-01
        • 2014-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多