FB OpenGraph og:image,链接文件夹?

Mar*_*ell 3 html meta-tags facebook-opengraph

我正在向项目添加元标记,并且我一直在阅读 OpenGraph 文档,但是每次我看到og:image接下来出现的内容总是一个 URL。是否可以使用相对路径传递文件?

文件结构:

public
   index.html
   images
    staticimage.png
Run Code Online (Sandbox Code Playgroud)

我可以只链接到图像路径吗?

public
   index.html
   images
    staticimage.png
Run Code Online (Sandbox Code Playgroud)

到目前为止,它似乎不起作用。

Sku*_*lly 5

相对 URL 不起作用,该og:image属性只能处理完整 URL。

og:image属性确实有一些可选的结构化属性:

  • og:image:url- 与 og:image 相同。
  • og:image:secure_url- 如果网页需要 HTTPS,则使用备用 URL。
  • og:image:type- 该图像的 MIME 类型。
  • og:image:width- 宽度的像素数。
  • og:image:height- 像素数高。
  • og:image:alt- 对图像内容的描述(不是标题)。如果页面指定 og:image 它应该指定og:image:alt

完整图像示例:

<meta property="og:image" content="https://example.com/ogp.jpg" />
<meta property="og:image:secure_url" content="https://secure.example.com/ogp.jpg" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="400" />
<meta property="og:image:height" content="300" />
<meta property="og:image:alt" content="A shiny red apple with a bite taken out" />
Run Code Online (Sandbox Code Playgroud)

来源: https: //ogp.me/#structured