Small preview when sharing link on Social media Ruby On Rails

≡放荡痞女 提交于 2019-12-06 01:37:50

You can set a custom image for you website to be shown in fb posts -

Add the OG XML to your html tag

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:fb="http://ogp.me/ns/fb#">

Add these meta tags to set the custom image that OG will use

<meta property="og:image" content="url_to_image" />

You can try reading this for more insight.

Hopefully this helps.

Johannes Ferner

You are correct, you need to implement special open graph (and other) tags for the customized social sharing functionalities.

Keep in mind that e.g. facebook will cache your page.

So you may try https://developers.facebook.com/tools/debug/ to test your code without caching - the code itself looks fine.

Example Code:

Place this code between <head> and </head> with your other meta tags.

<meta property="og:title" content="Title">
<meta property="og:site_name" content="Name">
<meta property="og:url" content="URL">
<meta property="og:description" content="Description Text">
<meta property="og:type" content="article">

<!--- network Specific --> 
<meta property="fb:app_id" content="AppID">
<meta name="twitter:card" content="app">
<meta name="twitter:site" content="@FernerJohannes">

If you want to target Twitter specifically here are their card-guidelines: https://dev.twitter.com/cards/getting-started

You may also want to checkout: Open Graph validation for HTML5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!