Sub topic 5
Description, Site Name, and Locale
The four core properties identify a page. This chapter covers the three properties that make a preview card readable and polished: og:description, og:site_name, and og:locale. Each is optional, but each changes what people see.
This chapter assumes you can write meta tags in a document <head>. It also assumes you know the core properties from the previous chapter (og:title, og:type, og:image, og:url) and that you can read basic JavaScript.
What these properties do
A preview card has a title and an image, and it usually has more. The descriptive properties fill in the rest:
| Property | Purpose | Typical value | Where it appears |
|---|---|---|---|
| `og:description` | One or two sentences summarizing the page | `A simple method for smooth cold-brew coffee at home.` | Under the title, often truncated |
| `og:site_name` | The name of the larger site the page belongs to | `Daily Grind` | Small label above or below the card |
| `og:locale` | The language and region of the page content | `en_US` | Not shown. Used by the platform for processing and translation hints |
| `og:locale:alternate` | Other locales in which the page is available | `es_ES` | Not shown |
The diagram shows how a crawler turns these tags into the parts of a card.
Writing og:description
og:description is a short summary of the page. Treat it as the second line of an advertisement. The title gets attention and the description gives a reason to click.
<meta property="og:description" content="A simple method for smooth cold-brew coffee at home.">Length
The Open Graph protocol sets no length limit. Platforms do, and they differ. Many cards show only the first 100 to 200 characters and cut the rest with an ellipsis. Some layouts, such as large-image cards on some platforms, show no description at all. Chat apps often show more text than feeds do.
A practical rule is to write a complete thought in about 110 to 160 characters. Put the most important words first, because truncation removes the end. Check the platforms you care about, since their limits change over time.
Write it for people, not for search
Do not stuff keywords into the description. The reader sees it in a feed next to messages from friends. Good descriptions:
- Say what the reader gets ("Step-by-step guide to...") instead of repeating the title.
- Use plain text. Do not include HTML tags or Markdown, because crawlers show them literally.
- Contain no line breaks that matter. Crawlers collapse whitespace.
- Avoid text that duplicates
og:title. A card that says the same thing twice wastes its space.
Relationship to the standard description tag
HTML also has a <meta name="description"> tag, which search engines read. It uses the name attribute, not property. The two tags have different audiences, so they can have different text.
<meta name="description" content="Cold brew takes 12 hours but only five minutes of work. This guide covers ratios, grind size, and storage.">
<meta property="og:description" content="Smooth cold brew at home: the ratio, the grind, and the 12-hour wait.">When og:description is missing, some crawlers fall back to name="description", and some show nothing. Do not rely on the fallback. If you do not want to maintain two texts, set both tags to the same string.
Generating a safe description from page text
When pages come from a CMS or a database, you often have a long body but no summary. A helper can trim the body to a limit at a word boundary. This function collapses whitespace, cuts at a word boundary where it can, and adds an ellipsis.
function toDescription(text, max = 160) {
const clean = String(text).replace(/\s+/g, " ").trim();
if (clean.length <= max) return clean;
const cut = clean.slice(0, max - 1);
const lastSpace = cut.lastIndexOf(" ");
const base = lastSpace > max * 0.6 ? cut.slice(0, lastSpace) : cut;
return base.replace(/[\s.,;:!?-]+$/, "") + "…";
}
const body = `
Cold brew coffee is made by steeping coarsely ground beans in cold water
for twelve hours or more. The result is smooth, low in acidity, and keeps
in the refrigerator for up to two weeks.
`;
console.log(toDescription(body));The output is a single line of at most 160 characters. The lastSpace > max * 0.6 check avoids cutting the text far too short when a very long word sits near the limit.
This helper does not escape HTML. Escape the value when you place it in a tag. The chapter on generating tags per page covers this in detail. Until then, remember that a " inside a description will end the content attribute early and break the tag.
Writing og:site_name
og:site_name names the site, not the page. If the page is "How to Brew Cold Coffee" on a site called "Daily Grind", then og:title is the first and og:site_name is the second.
<meta property="og:title" content="How to Brew Cold Coffee">
<meta property="og:site_name" content="Daily Grind">Some platforms show it as a small label near the card, often next to or above the title. Others use the domain name instead and ignore the tag.
Two common mistakes:
- Repeating the site name in every title. If
og:site_nameis set, you usually do not needHow to Brew Cold Coffee | Daily Grindas the title. The card can show both separately. Keep the<title>element as you like for browser tabs and search results, and use a shorterog:title. - Using a different name on each page. The value should be the same on every page of the site. Treat it as a site-wide constant in your configuration.
Writing og:locale
og:locale states the language and region of the page content.
<meta property="og:locale" content="en_US">The format
The format is language_TERRITORY. The language is a lowercase two-letter ISO 639-1 code. The territory is an uppercase two-letter ISO 3166-1 code. The two parts are joined with an underscore.
This differs from the HTML lang attribute, which uses BCP 47 tags with a hyphen, as in lang="en-US". Confusing the two is the most common locale mistake. If your site stores locale codes in the HTML style, convert them.
function toOgLocale(tag) {
const [lang, region] = String(tag).split(/[-_]/);
if (!lang || !region) return null;
return `${lang.toLowerCase()}_${region.toUpperCase()}`;
}
console.log(toOgLocale("en-us")); // en_US
console.log(toOgLocale("pt_br")); // pt_BR
console.log(toOgLocale("fr")); // nullThe function returns null for a bare language such as fr, because the protocol format needs both parts. Your calling code decides what to do then. A reasonable choice is to map the language to a default region (fr to fr_FR) from a table you maintain, or to omit the tag.
The default
If you omit og:locale, the protocol default is en_US. A French page without the tag is therefore described as American English. Platforms mostly use the locale for language hints, such as deciding whether to offer a translation, so a wrong value can cause odd behavior. Always set it on non-English pages.
Alternate locales
If the same content exists in other languages, list each one with og:locale:alternate. The tag can repeat, one line per locale.
<head>
<meta charset="utf-8">
<title>Cómo preparar café frío</title>
<meta property="og:title" content="Cómo preparar café frío">
<meta property="og:type" content="website">
<meta property="og:url" content="https://example.com/es/cafe-frio">
<meta property="og:image" content="https://example.com/images/cold-coffee-1200x630.jpg">
<meta property="og:description" content="Un método sencillo para preparar café frío suave en casa.">
<meta property="og:site_name" content="Daily Grind">
<meta property="og:locale" content="es_ES">
<meta property="og:locale:alternate" content="en_US">
<meta property="og:locale:alternate" content="pt_BR">
</head>Here og:locale describes this page, and the alternates describe other versions. Do not list the current locale as an alternate.
Each language version should be its own URL with its own tags, and the title and description should be in that page's language. Setting og:locale to es_ES while the title is in English does not translate anything. The tag describes the content and does not change it.
Putting it together in code
This helper builds the descriptive tags from one configuration object. It shows the shape of the data, with siteName as a site-wide constant and locale and alternates varying by page.
function escapeHtml(value) {
return String(value)
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """);
}
function descriptiveTags({ description, siteName, locale, alternates = [] }) {
const tags = [
["og:description", description],
["og:site_name", siteName],
["og:locale", locale],
...alternates.map((alt) => ["og:locale:alternate", alt]),
];
return tags
.filter(([, content]) => content)
.map(([property, content]) => `<meta property="${property}" content="${escapeHtml(content)}">`)
.join("\n");
}
console.log(
descriptiveTags({
description: 'Smooth cold brew: the "12-hour" method',
siteName: "Daily Grind",
locale: "en_US",
alternates: ["es_ES"],
})
);The filter call drops tags whose value is empty. An empty og:description is worse than a missing one, because some crawlers treat the empty value as final and skip any fallback. The quotes in the sample description come out as ", so the attribute stays intact.
Checking the result
Fetch the page the way a crawler does and list the descriptive tags:
curl -s -A "facebookexternalhit/1.1" https://example.com/cold-coffee \
| grep -iE 'property="og:(description|site_name|locale)'You should see one line each for the description and site name, one for the locale, and one per alternate. If a tag is missing here, the problem is in your HTML output and not in the platform. Platform debugging tools and cache refresh are covered in a later chapter.
Edge cases
- Very short descriptions. A description of a few words can look empty on a large card. Aim for a full sentence.
- Non-Latin text. Truncation counts characters, not bytes, and some scripts display wider. Test CJK and right-to-left text on real platforms. Save the file as UTF-8 and keep
<meta charset="utf-8">early in the head. - Dynamic content from user input. Descriptions taken from user posts can contain markup, emoji, or private text. Strip markup, escape the result, and decide whether the content is safe to expose to anyone who has the link.
- Locale and the shared URL. A crawler fetches one URL. If your server picks a language from the
Accept-Languageheader, the crawler gets whatever default you serve it. Give each language its own URL so the preview matches the page. - Changed text, same preview. After you edit a description, platforms may keep showing the old one from cache. This is expected and is handled by refreshing the cache.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Description cut off mid-sentence | Text longer than the platform allows | Put key information first and shorten to about 160 characters |
| Tag text breaks off at a quote | Value not escaped | Escape `"`, `&`, `<`, and `>` |
| Locale ignored or flagged | Hyphen used, as in `en-US` | Use `en_US` |
| French page treated as English | `og:locale` omitted, so default is `en_US` | Set `og:locale` to `fr_FR` |
| No description shown | Platform layout hides it, or tag missing | Check the HTML with `curl`, then try another platform |
| Site name missing on card | Platform does not display it | Nothing to fix. The tag is still valid |
Exercise
A Brazilian Portuguese page at https://example.com/pt/cafe-frio is also available in English and Spanish (Spain). Its CMS stores the page language as pt-BR. Write the three locale-related meta tags for this page, and explain why og:locale must not be written as pt-BR.
Show answer
<meta property="og:locale" content="ptBR"> <meta property="og:locale:alternate" content="enUS"> <meta property="og:locale:alternate" content="esES"> The Open Graph format is languageTERRITORY with an underscore, unlike the hyphenated BCP 47 form used by the HTML lang attribute. The current locale is not repeated in an alternate tag, and the alternate tag appears once per other language.
Exercise
A page has <meta property="og:description" content="Our "best" coffee guide"> and the preview shows the description as Our . What is wrong, and how do you fix it?
Show answer
The inner double quotes end the content attribute early, so the crawler reads only Our . Escape the quotes as ", giving content="Our "best" coffee guide", or escape every value with a helper such as escapeHtml before placing it in the tag.