ogp prefix 怎么写
官网的内容不好理解,我大概整理了一遍
my_namespace (类型)
- Music
- Video
- Article
- Book
- Profile
- Website (默认)
URL
https://ogp.me/ns/music#
https://ogp.me/ns/video#
https://ogp.me/ns/article#
https://ogp.me/ns/book#
https://ogp.me/ns/profile#
https://ogp.me/ns/website#
(默认)
当要使用类型时,需要一个 prefix
官网的 best practices 是写在 html 或者 head
<html prefix="og: https://ogp.me/ns#">
facebook best practice
<head prefix= "og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# product: http://ogp.me/ns/product#"> <meta property="og:type" content="og:product" /> <meta property="og:title" content="Friend Smash Coin" /> <meta property="og:image" content="http://www.friendsmash.com/images/coin_600.png" /> <meta property="og:description" content="Friend Smash Coins to purchase upgrades and items!" /> <meta property="og:url" content="http://www.friendsmash.com/og/coins.html" /> <meta property="product:plural_title" content="Friend Smash Coins" /> </head>
看到 xml... 就大概猜是 XHTML 的规范,希望猜的对。
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#">
image_src 看样子是早期的产物,官网也没有说这个废弃,可能是太久了吧
<link rel="image_src" href="https://www.your-website.com/open-graph.jpg">
Best practice
<html prefix="og: https://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="https://www.imdb.com/title/tt0117500/" /> <meta property="og:image" content="https://ia.media-imdb.com/images/rock.jpg" /> ... </head> ... </html>
工具
大致上就是这样。
Links
- https://ogp.me/
- https://www.popwebdesign.net/what-is-ogp.html
- https://stackoverflow.com/questions/27943451/meaning-of-html-prefix-attribute-open-graph-protocol
- https://developers.facebook.com/docs/sharing/webmasters#markup
- https://schema.org.cn/docs/faq.html#1
- https://developers.facebook.com/docs/payments/product/