Next.js 的 og 图像元标记不起作用

din*_*lal 10 html meta-tags next.js

<meta property="og:image" content="https://mywebsite.com/images/s1.jpg" 
Run Code Online (Sandbox Code Playgroud)

我使用了 next/head 并添加了上面的元标记图像,但是当我共享链接时,图像没有出现。我该如何修复它?

小智 8

对我来说它终于起作用了:Inside _app.js

import Head from "next/head"
Run Code Online (Sandbox Code Playgroud)

然后在返回中:

<Head>
<meta property="og:image" content="https://myurl.com/ogImage.png" />
</Head>
Run Code Online (Sandbox Code Playgroud)

然后我进行了静态导出并通过 FTP 从“out”文件夹上传文件,因为我将项目托管在非节点服务器上。为此,请打开“package.json”并将“导出”更改为“下一个构建&&下一个导出”。然后只需在控制台中运行 npm run export 即可将文件导出为 html


Ano*_*ngh 0

<head>您可以在标签中使用此元标签

<meta property="og:image" content="https://mywebsite.com/images/s1.jpg"/>

<meta property="og:title" content="Your Title"/>

<meta property="og:description" content="A full description of the page."/>

<meta property="og:image:width" content="1200"/>

<meta property="og:image:height" content="630"/>
Run Code Online (Sandbox Code Playgroud)

"/>"请正确关闭标签中遗漏的元标签。

  • @dinagaal你可以测试你的页面`https://developers.facebook.com/tools/debug/`使用元标记就像这样https://www.opengraph.xyz/url/http%3A%2F%2Fgarimadisposal.in %2F/ (2认同)