将元描述和 Open Graph Protocol 描述合二为一

2022-01-18 00:00:00 header tags html facebook-graph-api

是否可以将元描述和开放图协议描述结合起来......

Is it possible to combine the meta description and Open Graph Protocol description…

<meta name="description" content="My meta description copy." />
<meta property="og:description" content="My meta description copy." />

…当它们包含相同的内容时合二为一?

…into one when they contain the same content?

<meta name="description" property="og:description" content="My meta description copy." />

推荐答案

是的,你可以把它们结合起来.为了测试它,我制作了下面的简单 HTML 页面,将其上传到服务器,然后通过 Facebook 的 URL Linter.它没有报告与描述标签相关的警告(仅关于缺少的 og:image 标签)并正确读取了描述.

Yes, you can combine them. To test it, I made the simple HTML page below, uploaded it to a server, then ran the page through Facebook's URL Linter. It reported no warnings related to the description tag (only about the missing og:image tag) and correctly read the description.

<!doctype html>
<html>
    <head>
        <meta name="description" property="og:description" content="My meta description copy." />
        <meta property="og:title" content="Test page" />
        <meta property="og:type" content="article" />
        <meta property="og:url" content="http://example.com/ogtest.html" />
    </head>
    <body>
    Test
    </body>
</html>

请注意,如果 og:url 值与当前页面的 url 不同,Facebook 将在该 url 上查找描述而不是当前的描述,并忽略当前页面的描述标签.

Note that, if the og:url value is different to the current page url, Facebook will look for a description on that url instead of the current one and ignore the current page's description tag.

您可能还想知道,即使可以将两个描述标签组合在一起,Facebook 也不会在他们自己的网站上这样做.

It might also interest you to know that, even though it's possible to combine the two description tags, Facebook doesn't do this on their own website.

相关文章