Google+分享自定义文字和缩略图 [英] Google+ share with custom text and thumbnail

查看:59
本文介绍了Google+分享自定义文字和缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为Facebook创建共享链接时,您可以通过执行以下操作来个性化共享链接:

While creating sharing links for facebook, you can personalize a sharing link by doing something like :

<a title='Share on Facebook' 
href='http://www.facebook.com/sharer.php?s=100
&p[title]=TITLE_HERE
&p[summary]=TEXT_HERE
&p[url]=URL_HERE
&p[images][0]=URL_TO_IMAGE' target='_blank' >
<img alt="Facebook" src="ICON_URL" />
</a>

有没有一种方法可以与Google+类似,而不必在标头中填充meta标签(因为我需要在一页中包含许多共享链接)

Is there a way to do something similar with Google+, instead of having to fill the meta tags in the header (because I need many sharing links in one page)

推荐答案

您可以为此使用schema.org微数据.这些不是在站点头部创建的标签,而是分配给特定节点的属性.这是一个如何工作的示例:

You can use schema.org microdata for that. These are not tags made in the site's head, but instead properties you assign to the specific nodes. Here's an example of how it could work:

假设您有一个博客,其中有多篇文章,每篇文章都应该有自己的+1按钮.在每篇文章的最外层节点(如果您使用的是HTML5语义,则可能为<article>),您将定义一个新的itemscope以及特定的itemtype(在本例中为"http://schema.org/BlogPosting",请参见所有类型的列表).

Let's say you have a blog with multiple article, each of which should have its own +1 button. In the outermost node of each article (if you're using HTML5 semantics, it'll probably be <article>), you define a new itemscope along with the specific itemtype (in this case "http://schema.org/BlogPosting", see the list of all types).

接下来,您使用itemprop字段注释共享片段中应包含的字段.例如,如果文章中有图片,则可以用itemprop="image"标记<img>节点,依此类推.

Next, you annotate the fields that should be included in the share snippet using the itemprop field. For example, if the article has an image, the <img> node could be annotated with itemprop="image" and so on.

请注意,这些注释仅在当前itemscope中有效. +1按钮也必须放置在此范围内,因为它会查找DOM层次结构中位于按钮上方的第一个项目范围.

Note that these annotations are only valid in the current itemscope. The +1 button has to be placed inside this scope as well, since it looks for the first itemscope that occur above the button in the DOM hierarchy.

积极的一面是,您可以在每页上定义多个项目范围,从而轻松地在其上集成具有不同共享片段的多个+1按钮.

The positive side of that is that you can define multiple itemscopes per page, thus easily integrate multiple +1 buttons with different share snippets on it.

有关更多信息,请参见 +1按钮文档.

More info is also available on the +1 button documentation.

这篇关于Google+分享自定义文字和缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆