You share a link in a WhatsApp group, and a small card appears with a picture and a title. But you only pasted the address. How does WhatsApp know which picture to use?
From meta tags: tags inside <head> that hold information about the page. They don't show on the page. The browser and Google read them, and so do chat apps when your link is shared.
What every page needs in <head>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mrs. Sri's Stall</title>
<meta name="description" content="Coconut rice, black coffee and warm sweet tea.">
</head>
<head>is the top part of the page, before<body>. It holds information about the page, not the content that shows on it.<meta>is a tag for one piece of information. It has no closing tag.<meta charset="UTF-8">tells the browser how to read the letters on the page. UTF-8 is a way of storing letters that covers almost every letter in the world. Without this line, a symbol like © can show as strange characters.<meta name="viewport" content="...">makes the page as wide as the phone's screen. Without this line, a phone browser treats the page as wide as a laptop screen and then shrinks it. The text becomes very small. Do not adduser-scalable=noormaximum-scale=1to this line: in many phone browsers, visitors can then no longer zoom in on the text with two fingers, and many people need to.<title>is the page's title. It shows in the browser tab and as the title in Google results. Unlike meta,<title>has a closing tag.<meta name="description" content="...">is a summary of the page. Google often shows it under the title in search results.
A meta with name always comes with content: name says what the information is about, and content holds its value. None of this is visible on the page. The page still shows only the content of <body>.
Preview cards with Open Graph
When a link is shared, WhatsApp, Facebook and LinkedIn build a preview card from the Open Graph meta tags. Open Graph is a set of meta tags made to fill that card:
<meta property="og:title" content="Mrs. Sri's Stall">
<meta property="og:description" content="Coconut rice breakfast from $2.">
<meta property="og:image" content="https://example.com/stall/og.jpg">
<meta property="og:type" content="website">
- Open Graph meta tags use the
propertyattribute, notname. The value ofpropertyalways starts withog:. og:titleis the card's title,og:descriptionits description,og:imageits picture (a full address fromhttps://), andog:typethe kind of page, such aswebsiteorarticle.- Each meta carries one value, in its own
content. The title goes inog:title, so don't put it inog:descriptionby mistake.
⚠️ Meta tags in the wrong place, empty, or all the same
- Meta tags in
<body>. Every meta and the<title>go between<head>and</head>. - An empty or missing
content.<meta property="og:title">with nocontentsays nothing. namefor Open Graph. The correct attribute isproperty:<meta property="og:title" ...>.- A description that is too long. Google usually cuts it at around 150 to 160 characters. Keep it short.
- The same title on every page. Each page needs its own title, so people can see which page is which in tabs and on Google.
TL;DR: Meta tags hold information about the page. They go in <head> and don't show on the page. Every page needs <meta charset="UTF-8">, a viewport meta so it fits on phones, and a <title>. Add a description meta for the summary on Google. For the preview card that chat apps show when a link is shared, use Open Graph: <meta property="og:..." content="..."> for og:title, og:description, og:image and og:type.
⚡ Information that doesn't show
Write:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mrs. Sri's Stall</title>
<meta name="description" content="Coconut rice, black coffee and warm sweet tea.">
</head>
Meaning: Meta tags hold information about the page. All of this goes in <head> and doesn't show on the page. charset="UTF-8" makes symbols like © show correctly. <title> shows in the tab and as the title in Google results. description is the summary often shown under it.
⚡ Fit on a phone screen
Guess first: without the viewport meta, how does your page look on a phone?
The text is very small. The phone browser treats the page as wide as a laptop screen, then shrinks it.
Meaning: The viewport meta makes the page as wide as the phone's screen.
⚡ Preview cards with Open Graph
Write:
<meta property="og:title" content="Mrs. Sri's Stall">
<meta property="og:image" content="https://example.com/stall/og.jpg">
Meaning: When a link is shared, WhatsApp and Facebook read these meta tags to build a preview card (a small card with the title and picture). These meta tags are called Open Graph: they use property, not name, the value of property starts with og:, and the text goes in content.