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." />
2 个解决方案
#1
41
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.
是的,你可以合并它们。为了测试它,我制作了下面这个简单的HTML页面,将它上传到服务器上,然后通过Facebook的URL链接器运行这个页面。它没有报告任何与描述标记相关的警告(只报告丢失的og:图像标记),并正确地读取描述。
<!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>
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.
注意,如果og:url值与当前页面url不同,Facebook将查找该url上的描述而不是当前url,并忽略当前页面的描述标记。
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.
你可能也会感兴趣,即使你可以把这两个描述标签结合起来,Facebook在他们自己的网站上也不会这样做。
#2
5
Some additional info on why this is possible/allowed:
关于为什么这是可能的/允许的一些附加信息:
HTML+RDFa 1.1 extends HTML5’s meta
element.
HTML+RDFa 1.1扩展了HTML5的meta元素。
HTML+RDFa 1.1 (W3C Recommendation) defines:
HTML+RDFa 1.1 (W3C推荐标准)定义:
If the RDFa @property attribute is present on the meta element, neither the @name, @http-equiv, nor @charset attributes are required and the @content attribute MUST be specified.
如果在元元素上存在RDFa @property属性,则不需要@name、@http-equiv和@charset属性,必须指定@content属性。
So when using RDFa's @property the name is not required but it is not forbidden either, making
因此,当使用RDFa的@property时,不需要名称,但也不禁止,创建
<meta name="description" property="og:description" content="great description">
perfectly ok according to spec.
根据规格完全可以。
I found this from the answer to this related question: Is it possible to use the same meta tag for opengraph and schema.org
我从这个相关问题的答案中发现了这一点:是否可能对opengraph和schema.org使用相同的meta标记
#1
41
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.
是的,你可以合并它们。为了测试它,我制作了下面这个简单的HTML页面,将它上传到服务器上,然后通过Facebook的URL链接器运行这个页面。它没有报告任何与描述标记相关的警告(只报告丢失的og:图像标记),并正确地读取描述。
<!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>
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.
注意,如果og:url值与当前页面url不同,Facebook将查找该url上的描述而不是当前url,并忽略当前页面的描述标记。
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.
你可能也会感兴趣,即使你可以把这两个描述标签结合起来,Facebook在他们自己的网站上也不会这样做。
#2
5
Some additional info on why this is possible/allowed:
关于为什么这是可能的/允许的一些附加信息:
HTML+RDFa 1.1 extends HTML5’s meta
element.
HTML+RDFa 1.1扩展了HTML5的meta元素。
HTML+RDFa 1.1 (W3C Recommendation) defines:
HTML+RDFa 1.1 (W3C推荐标准)定义:
If the RDFa @property attribute is present on the meta element, neither the @name, @http-equiv, nor @charset attributes are required and the @content attribute MUST be specified.
如果在元元素上存在RDFa @property属性,则不需要@name、@http-equiv和@charset属性,必须指定@content属性。
So when using RDFa's @property the name is not required but it is not forbidden either, making
因此,当使用RDFa的@property时,不需要名称,但也不禁止,创建
<meta name="description" property="og:description" content="great description">
perfectly ok according to spec.
根据规格完全可以。
I found this from the answer to this related question: Is it possible to use the same meta tag for opengraph and schema.org
我从这个相关问题的答案中发现了这一点:是否可能对opengraph和schema.org使用相同的meta标记