0

I have done as the guide in Optimize Tweets with Cards, but it does not work like put my image and description in a card to share to others.

I want to share my webpage in a card for twitter.

<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="summary" />
<meta name="twitter:creator" content="summary" />
<meta name="twitter:image" content="https://stackoverflow.com/questions/56339282/how-to-share-my-webpage-to-twitter-in-a-card/are_6b65b534.jpg" />
<meta name="twitter:description"   content="@ViewBag.Description" />

As I put the guide code in my webpage, I still just get a url when I share my webpage.

Thanks for your help.

Wament
  • 21
  • 4
  • Maybe your URL for the image is wrong ? Did you try with an external image like this one : http://lorempixel.com/400/200/, maybe you need to change summary to summary_large_image and add twitter:url there. – Zied Hf May 28 '19 at 09:46
  • @ZiedHf yes,I have tried it,it does not work,too. – Wament May 28 '19 at 09:48
  • 1
    Images have to be URLs, not paths. Also, you might run into a caching issue so that changes to that information will not be reloaded by Twitter. – str May 28 '19 at 09:49
  • @str thank you,I wanna make it easy,so I fill the image content casuallyψ(._. )>And how can I clean the cache – Wament May 28 '19 at 09:53
  • https://stackoverflow.com/questions/28207497/how-to-force-cache-purge-of-twitter-cards-bots – str May 28 '19 at 09:53

2 Answers2

1

You have to state the full URL of the image for it to work. Test it here: https://cards-dev.twitter.com/validator

Pie
  • 584
  • 1
  • 6
  • 22
0

Please add the property attributes like:

<meta property="og:url" content="http://bits.blogs.nytimes.com/2011/12/08/a-twitter-for-my-sister/" />
<meta property="og:title" content="A Twitter for My Sister" />
<meta property="og:description" content="In the early days, Twitter grew so quickly that it was almost impossible to add new features because engineers spent their time trying to keep the rocket ship from stalling." />
<meta property="og:image" content="http://graphics8.nytimes.com/images/2011/12/08/technology/bits-newtwitter/bits-newtwitter-tmagArticle.jpg" />

Please the example from twitter Optimize Tweets with Cards. Also try to add full path of image like the example and full content in description tag.

saifur
  • 637
  • 4
  • 17
  • I have tried the code at first,emmm but it has not worked.Is it something about robot.txt?It shows that "ERROR: Fetching the page failed because it's denied by robots.txt." in [https://cards-dev.twitter.com/validator],and I tried it on my phone. – Wament May 28 '19 at 09:58
  • Yes, if your robots.txt file denies access to the Twitterbot crawler, this will fail. – Andy Piper May 28 '19 at 12:01
  • emmm,therer is not a robots.txt in my sevrer.Does it still block the access? – Wament May 29 '19 at 06:03