Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Minimal Social Meta Tags for a Blog

DZone's Guide to

Minimal Social Meta Tags for a Blog

Learn how to factor out the repetition of meta tags when sharing a blog article on a social media site by modifying Open Graph protocol.

· Web Dev Zone
Free Resource

Should you build your own web experimentation solution? Download this whitepaper by Optimizely to find out.

When someone shares your blog article on a social network, odds are it will appear with some descriptive text, images, and so on. If your blog lacks explicit instructions, in many cases these properties are just guessed-at and won’t be great.

I’ve seen a lot of blog authors and template creators go too far in the other direction and add tons of redundant meta tags, which will make the page larger, heavier, and slower.

What’s the minimal necessary set of tags?

Most social media networks recognize various types of meta properties. Unfortunately, there’s a lot of redundancy amongst them. Fortunately, most of them also fall back to an open standard called the Open Graph protocol, so you can factor out the repetition.

For most blogs, and for the most popular social media for sharing informative articles (Twitter, Facebook, Google+, and LinkedIn), you need the following properties:

<meta name="og:type" content="article" />
<meta name="og:title" content="{content title, without site title}" />
<meta name="og:url" content="{permalink}" />
<meta name="og:image" content="{featured image}" />
<meta name="og:description" content="{description < 200 chars}" />
<meta name="og:site_name" content="{site title}" />

Some of these might seem redundant, but for example the URL is required for some services. In addition, for Twitter you’ll need the following:

<meta name="twitter:card" content="{desired card type}" />
<meta name="twitter:site" content="{your @username}" />

With those eight meta tags you’re all set for most content-related sharing. Other social media services, such as Pinterest, have additional tags they require, and sometimes processes you need to follow to be whitelisted.

All of the social media services have a) documentation and b) validators to preview how things will appear. Here are documentation links:

In many cases your content-sharing instructions won’t be honored until you use the validator to check it. Checking triggers and re-scraping serves as a whitelisting process for several of the networks.

Implementing an Experimentation Solution: Choosing whether to build or buy?

Topics:
meta tags ,meta data ,blog

Published at DZone with permission of Baron Schwartz, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}