开放图协议 - 如何使其适用于页面上的多个故事?
开放图谱协议是一种存储元数据的新方法,使第三方网站更容易使用(想想 Facebook 的 LIKE 按钮)识别页面上的相关内容。
它看起来像这样:
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="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" />
问题是,如果页面上有多个 LIKE 按钮,每个按钮对应一篇不同的文章,如何区分属于该文章而不是页面本身的 Open Graph 元标记。由于标签位于 HEAD 中,因此每页似乎只能获得一组标签。
开放图谱是否可以“命名空间”或与页面内的内容(而不是页面本身)相关联?
The Open Graph Protocol is a new methodology for storing metadata to make it easier for third party sites (think the Facebook LIKE button) to identify relevant content on your page.
It looks like this:
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="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" />
The question is, if you have multiple LIKE buttons on a page, each for a different article, how does one differentiate the Open Graph meta tags that belong to the article, not the page itself. Since the tags go in the HEAD is seems you only get one set per page.
Can Open Graph be "namespaced" or associated with content within the page, rather than the page itself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
据我所知,你被困住了 - 但如果你找到办法,请告诉我!
我从事的项目需要在一个页面上有多个开放图谱标签 - 最后,我们最终减少了需要 OG 的项目数量,这样我们在一页上只有一个故事。
As far as I know, you're stuck - but if you figure out a way, let me know!
I worked on a project that needed to have multiple Open Graph tags on a page - in the end, we ended up trimming down the number of items we needed OG for, so that we'd only have one story on a page.
我能想到的就是使用
。
每篇文章都有自己的页面,适合放置在另一个页面内。
然后您可以在母版页中显示所有这些文章。
All I can think of is using
<iframe>
.Each article is gonna have its own page, suitable to be placed inside another page.
And then you can display all those articles inside the master page.
如果每个“赞”按钮与同一页面上的一个项目相关联,则每个项目的标题可以链接到仅该项目的页面。该页面可以携带该项目的所有元标记,并且喜欢按钮将使用该页面的 url。我在这里做了这个
http://cinema-shorts.org/past/
(PS这是我建立的第一个正确的网站,所以如果它坏了请原谅我)
If each like button is associated with an item on the same page, then header of each item could link through to a page for just that item. That page could carry all the meta tags for the item and like button would use the url of that page. I did this here
http://cinema-shorts.org/past/
(P.S. this is the first proper website Ive built so if its broken please forgive me)
每个对象都由唯一的 URL 表示,因此单个页面上不能存在多个对象。
您可以在一个页面上有多个类似按钮,但必须使用
href
属性将每个按钮设置为指向不同的 URL。您可以让每个对象 URL 执行 JavaScript 重定向 (window.location.href = new_url),以使到达每个对象页面的用户被重定向到单个用户可见的页面。
Each object is represented by a unique URL so, no, multiple objects cannot exist on a single page.
You can have multiple like buttons on one page, but each must be set to point at a different URL by using the
href
attribute.You can make each of your object urls do a JavaScript redirect (window.location.href = new_url) to make users who arrive at each of your object pages be redirected to a single user-visible page.