我正在为一个项目添加meta标签,在阅读OpenGraph文档时,每次看到og:image
后面总是跟着一个URL。是否可以传递相对路径的文件?
文件结构:
public
index.html
images
staticimage.png
我能直接链接到图片路径吗?
<meta property="og:image" content="./images/staticimage.png" />
到目前为止,似乎它并没有起作用。
我正在为一个项目添加meta标签,在阅读OpenGraph文档时,每次看到og:image
后面总是跟着一个URL。是否可以传递相对路径的文件?
文件结构:
public
index.html
images
staticimage.png
我能直接链接到图片路径吗?
<meta property="og:image" content="./images/staticimage.png" />
到目前为止,似乎它并没有起作用。
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" />
Source: https://ogp.me/#structured