DEV Community


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

markusende profile image
Markus Ende

I don't think this will work. According to the "crawler and validator cannot execute Javascript and the tags must be static".

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 You can also see it working with one of my tweets:

markusende profile image
Markus Ende • Edited

It works because of this code part on your page:

  let origin = "";
  if (typeof window !== "undefined") {
    origin = window.location.origin;

Twitterbot will use something like this to crawl the site:
curl -v -A Twitterbot

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