Twitter Cards -- image does not work #32100
Replies: 4 comments
-
I am running into the exact same issue. Externally hosted photos are displaying fine on the Twitter card, but no image is rendered when I use a locally hosted one. The issue is happening exclusively with Twitter cards for me -- the image is loading fine on Facebook and LinkedIn. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks for the issue! To make the process of resolving problems quicker for both sides we need you to fill out the issue template and give us a minimal reproduction: <!--
Please fill out each section below, otherwise, your issue will be closed. This info allows Gatsby maintainers to diagnose (and fix!) your issue as quickly as possible.
Useful Links:
- Documentation: https://www.gatsbyjs.com/docs/
- How to File an Issue: https://www.gatsbyjs.com/contributing/how-to-file-an-issue/
Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
-->
## Description
Describe the issue that you're seeing.
### Steps to reproduce
Clear steps describing how to reproduce the issue. **Please** link to a reproduction, this makes your issue _much_ easier to diagnose (seriously).
How to Make a Minimal Reproduction: https://www.gatsbyjs.com/contributing/how-to-make-a-reproducible-test-case/
### Expected result
What should happen?
### Actual result
What happened.
### Environment
Run `gatsby info --clipboard` in your project directory and paste the output here. Also name any `flags` you use inside `gatsby-config.js`. |
Beta Was this translation helpful? Give feedback.
-
@LekoArts Updated with a reproduction. |
Beta Was this translation helpful? Give feedback.
-
Your error lies here:
<meta data-react-helmet="true" name="twitter:image" content="undefined/static/03475800ca60d2a62669c6ad87f5fda0/58026/energy.jpg"/> The starters or our examples (https://www.gatsbyjs.com/docs/add-seo-component/) you'll see use the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
This issue (unsolved) is described on Stack Overflow here. I'm relatively certain this has to do with Gatsby image processing, as replacing the content of my meta tags with an externally hosted image seems to work fine. Someone got in touch with me by email to share an identical issue, on Gatsby 3.1.2.
The issue is that my application, which uses react-helmet and gatsby-plugin-react-helmet, handles all Facebook (etc) meta tags just fine, and passes the Twitter card validator without error, but does not show an image on the validator or on Twitter, despite the image being specified in both a
twitter:image
meta tag and anog:image
metatag (both the complete URL).The images are hosted "locally" using Netlify CMS, and the app is on Netlify. I'm on Gatsby 2, as you can see below. Could try to update if that's a plausible cause of the issue, but it seems to be occurring for this other person on Gatsby 3 as well.
Also, if it's relevant, here's how I tried configuring
gatsby-plugin-robots-txt
, which should (I think) allow the Twitterbot to access the directory with my images:When that didn't fix things, I reverted to a default configuration:
Rather than duplicate the rest of the issue here, I'm just linking to the SO post, but if you would prefer, I can move it here.
Steps to Reproduce
src/images
pulled in via theallImageSharp
query.Below are two simplified reproductions.
The first included Netlify CMS, which I thought might have been part of the problem. Here it is. It's based off of this starter template, with Uploadcare/Cloudinary removed and Twitter card metadata added to the header. Other than that, and removing unnecessary pages, I didn't make any other changes. I used this starter for a repro rather than a vanilla starter app, because I'm unsure whether the issue is caused by the interaction of Netlify CMS and the Gatsby Sharp Image plugin. I might try to put together a second reproduction. For now, the code for this repo is here, and the pages that should show Twitter cards are the blog posts, such as this one.
The second is a super basic reproduction, with Gatsby 3 and no Netlify CMS or anything, and it has the same issue. Here's the minimal reproduction, with the image taken from
src/images
using anallImageSharp
query and inserted into the metadata for each page. Code here.Expected Result
Twitter images display.
Actual Result
Twitter images are not displaying on Twitter cards. Facebook, LinkedIn, etc display just fine. No errors are raised by Twitter validator.
Environment
No flags in my config.
Beta Was this translation helpful? Give feedback.
All reactions