简体   繁体   English

在我的HTML中添加到外部网站的链接及其摘要

[英]Adding a link to external website and it's synopsis in my HTML

In facebook, when I add a link to a website, it automatically brings some synopsis (text and images) from the external website and adds it to the page... 在facebook中,当我添加到网站的链接时,它会自动带来来自外部网站的摘要(文本和图像)并将其添加到页面中。

Something like this: 像这样:

在此处输入图片说明

How can this be done? 如何才能做到这一点? I simply don't know where to start and what to google to find a tutorial about this. 我只是不知道从哪里开始,以及从Google那里找到有关此的教程。

What you're looking for are Open Graph Meta Tags . 您正在寻找的是Open Graph Meta Tags By including these in the <head> of your page, Facebook can then use this information to generate useful previews. 通过将这些内容包括在页面的<head>中,Facebook可以使用此信息来生成有用的预览。

To turn your web pages into graph objects, you need to add basic metadata to your page. 要将网页变成图形对象,您需要向页面添加基本元数据。 We've based the initial version of the protocol on RDFa which means that you'll place additional <meta> tags in the <head> of your web page. 我们已将协议的初始版本基于RDFa,这意味着您将在网页的<head>中放置其他<meta>标签。 The four required properties for every page are: 每个页面的四个必需属性是:

og:title - The title of your object as it should appear within the graph, eg, "The Rock". og:title-对象的标题,因为它应该出现在图形中,例如“ The Rock”。

og:type - The type of your object, eg, "video.movie". og: type-对象的类型,例如“ video.movi​​e”。 Depending on the type you specify, other properties may also be required. 根据您指定的类型,可能还需要其他属性。

og:image - An image URL which should represent your object within the graph. og:image-图像URL,应表示图形中的对象。

og:url - The canonical URL of your object that will be used as its permanent ID in the graph, eg, " http://www.imdb.com/title/tt0117500/ ". og:url-对象的规范URL,将在图形中用作其永久ID,例如“ http://www.imdb.com/title/tt0117500/ ”。

As an example, the following is the Open Graph protocol markup for The Rock on IMDB: 例如,以下是The Rock on IMDB的Open Graph协议标记:

 <html prefix="og: http://ogp.me/ns#"> <head> <title>The Rock (1996)</title> <meta property="og:title" content="The Rock" /> <meta property="og:type" content="video.movie" /> <meta property="og:url" content="http://www.imdb.com/title/tt0117500/" /> <meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" /> ... </head> .... </html> 

The excerpt above, as well as additional properties and information, can be found here: The Open Graph protocol . 上面的摘录以及其他属性和信息可以在这里找到: Open Graph协议

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM