October 14, 2020

Blogger: share to twitter including post preview with pictures

 I was looking for a way while sharing one of my Blogger blog post to twitter to embed some nice blog preview including images.

I have this solution here: https://www.kimsixbloggersupport.com/2016/04/how-to-add-twitter-cards-to-your.html 

Edit your blog HTML template

After

<b:includable id='post' var='post'>

you shall add

<meta content='summary' name='twitter:card'/> 
<meta content='@tdalon' name='twitter:site'/>
<meta content='@tdalon' name='twitter:creator'/>
<meta content='https://tdalon.blogspot.com' name='twitter:domain'/>
<meta expr:content='data:post.firstImageUrl' name='twitter:image:src'/>
<meta expr:content='data:post.title' name='twitter:title'/>
<b:if cond='data:blog.metaDescription'>
 <meta expr:content='data:blog.metaDescription' name='twitter:description'/>
<b:else/>
 <meta expr:content='data:post.snippet' name='twitter:description'/>
</b:if>
<meta expr:content='data:post.sharePostUrl' name='twitter:url'/>

Replace in this block by your blog url and twitter username.

Then when you share the link to twitter you will have below a blog post preview in a so-called twitter card:


Note: for the preview to work you shall use the link without the URL shortening/ redirect removing the date path and HTML - if you use such a thing - as explained in a previous post here.

I like to get this link from the index/search/ list view by right-clicking on the post header and copy link address.



No comments:

Post a Comment