Combining the meta description and Open Graph Protocol description into one tag
Asked Answered
A

2

48

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." />
Abecedary answered 1/6, 2011 at 14:36 Comment(3)
nice question, sir! You probably need to change accepted answer as second one is better.Dyann
May I ask... why would you think its important to do this?Supporter
@Supporter to reduce duplication and page weightDrat
C
60

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>

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.

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.

Cherubini answered 1/6, 2011 at 15:53 Comment(2)
Can anyone think of any disadvantages of combining the two?Overstep
Wow, what a great idea! I've always hated the idea of duplicating that text/code at the top of the HTML document. Of course, this assumes that you want the same description to show up on a search result page OR social media site... which is probably the vast majority case.Matronize
A
11

Some additional info on why this is possible/allowed:

HTML+RDFa 1.1 extends HTML5’s meta element.

HTML+RDFa 1.1 (W3C Recommendation) defines:

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.

So when using RDFa's @property the name is not required but it is not forbidden either, making

<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

Accuracy answered 10/4, 2014 at 9:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.