DEV Community

loading...

Discussion on: Use Front Matter Images for Twitter Card Images in GatsbyJS

Collapse
codypearce profile image
Cody Pearce Author

Gatsbyjs renders all of this statically. You can test this is working on any page of my site using the official card validator too cards-dev.twitter.com/validator. You can also see it working with one of my tweets: twitter.com/codyapearce/status/123...

Collapse
markusende profile image
Markus Ende • Edited

It works because of this code part on your page:

  let origin = "https://codinhood.com/";
  if (typeof window !== "undefined") {
    origin = window.location.origin;
  }

Twitterbot will use something like this to crawl the site:
curl -v -A Twitterbot https://codinhood.com/post/visualizing-apple-deaths.

The window will not be available there. You can see that in the curl response, because there you have a duplicate slash character in you URL.

Thread Thread
jinoantony profile image
Jino Antony

You are right