2016-11-24 190 views
3

我希望用户在Twitter上分享我的网站页面。我有一个按钮,如下: -在Twitter上共享没有显示图片的缩略图

<a href="http://twitter.com/intent/tweet?text={{title}}&url=http://{{request.get_host}}/ad/{{slug}},{{id}}" target="_blank"></a> 

我的meta标签如下: -

<meta property="og:type" content="website" /> 
<meta property="og:title" content="{{title}}" /> 
<meta property="og:description" content="{{description}}" /> 
<meta property="og:image" itemprop="image primaryImageOfPage" content="http://{{request.get_host}}{{images.0}}" /> 
<meta property="og:url" content="http://{{request.get_host}}/ad/{{slug}},{{id}}"/> 
<meta name="twitter:card" content="summary"> 
<meta name="twitter:domain" content="{{request.get_host}}"/> 
<meta name="twitter:title" property="og:title" itemprop="title name" content="{{title}}" /> 
<meta name="twitter:description" property="og:description" itemprop="description" content="{{description}}" /> 

This是我点击共享链接后,我得到什么。 我的预期(理想)结果应该像this。我错过了什么?

This是我想分享的页面。

回答

2

我刚刚在Twitter Cards Validator中检查了您的页面,这表明twitter:description字段丢失。根据您发布的内容,它在那里,但是您已经添加了其他内容(property="og:description" itemprop="description"),这意味着卡片抓取工具无法正确解析它。最重要的是,我刚刚检查了您的网站,twitter:description的值实际上是空白的,所以这不起作用。我猜content="{{description}}"返回一个空值,所以你应该看看。

+0

感谢Andy的帮助。那么,我检查了它,说明字段实际上是空的。有没有一种方法可以绕过这一点,还是强制提供描述字段? – PythonEnthusiast

+0

这是一个必填字段,您将在[卡片文档](https://dev.twitter.com/cards)中看到。你需要让你的页面有一个可以传递到Twitter标签的'{{description}}值,否则验证器不会通过该卡片。 –