Sub topic 7
How search snippets are generated
This chapter assumes you know the basic HTML head and body structure, the role of the title tag and meta description, and what a results page looks like. It covers how a search engine decides which text to show under a result, which signals you control, and which you don't.
What a snippet is
A snippet is the block of text shown under the title and URL of a search result. It is not a copy of your meta description. Google states that it generates snippets automatically from page content, and that it uses the meta description only when that description describes the page better than text taken from the page itself. Bing works in a similar way.
The snippet is therefore a selection, made at query time. The same page can show different snippets for different searches.
The selection process
When a page is indexed, the search engine stores its extracted text, its meta description, and any structured data. When a user searches, the engine ranks matching pages. For each ranked page it then chooses the text that best answers that query.
Two consequences follow from this model.
- A description that is generic or off-topic loses to body text. It is still indexed, but it is rarely shown.
- A description that covers the main topic of the page is more likely to be used for broad queries. Long-tail queries often pull a passage from the body, because the body contains the specific words the description leaves out.
Signals that feed a snippet
| Source | Role | Your control |
|---|---|---|
| Visible body text | Main source. Passages are matched to the query. | Write clear, self-contained paragraphs near relevant headings. |
| Meta description | Candidate summary. Used when it fits the query better than the body. | Full control of the text. No control over whether it is chosen. |
| Structured data | Can add rich result elements such as ratings, prices, or dates. | Add valid markup that matches visible content. |
| Robots directives | Limit or forbid snippet text. | Full control. |
| Page language and encoding | Affect how text is extracted and truncated. | Set `lang` and `charset` correctly. |
Length limits and truncation
There is no fixed character limit. Search engines truncate by pixel width, so the visible length depends on the letters used and on the device. A common working range is about 120 to 160 characters for a description. Mobile and desktop results can cut at different points, and the engine may show longer text than that when it picks a body passage.
Truncation is cosmetic, not a penalty. A cut-off description is still indexed in full. What you lose is the end of your sentence, so put the most important information first.
Controlling snippets with robots directives
You can restrict what search engines show. These controls apply to snippets, not to ranking.
nosnippetin a robots meta tag removes the text snippet entirely. It also prevents the page from being used as a source for some features, such as featured snippets.max-snippet:Nlimits the text snippet to N characters.max-snippet:0is the same asnosnippet, andmax-snippet:-1means no limit.data-nosnippetis an HTML attribute onspan,div, orsectionelements. It excludes only that part of the page from snippets. The page text is still indexed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Trail Running Shoes for Beginners | Example Store</title>
<meta name="description" content="Compare cushioned trail running shoes for first-time runners, with fit tips and a size guide.">
<meta name="robots" content="max-snippet:160">
</head>
<body>
<h1>Trail Running Shoes for Beginners</h1>
<p>Start with a shoe that has a lugged outsole and a wide toe box.</p>
<p>Our fit guide explains how to size up for long descents.</p>
<div data-nosnippet>
<p>Internal note: price match offer valid until the end of the month.</p>
</div>
</body>
</html>Here the snippet is capped at 160 characters, and the price-match note will not appear in any snippet.
Two details cause confusion:
data-nosnippetis parsed after the page is rendered, so content added by JavaScript is handled only if the engine renders the page. Put the attribute in the server HTML where you can.- A robots meta tag with
nosnippetapplies to the whole page. If you only need to hide one block, usedata-nosnippet.
Checking your own descriptions
You can't see what a search engine will choose, but you can check what you are offering. This script reads a page's description and robots tags and flags common problems. It runs as shown and uses only the standard library.
from html.parser import HTMLParser
class MetaReader(HTMLParser):
def __init__(self):
super().__init__()
self.description = None
self.robots = None
def handle_starttag(self, tag, attrs):
if tag != "meta":
return
attributes = dict(attrs)
name = (attributes.get("name") or "").lower()
if name == "description":
self.description = attributes.get("content")
elif name == "robots":
self.robots = attributes.get("content")
def check(html):
reader = MetaReader()
reader.feed(html)
problems = []
if not reader.description:
problems.append("missing description: engine will use body text")
elif len(reader.description) > 160:
problems.append(f"long description ({len(reader.description)} chars): likely truncated")
elif len(reader.description) < 70:
problems.append(f"short description ({len(reader.description)} chars): little to match")
if reader.robots and "nosnippet" in reader.robots.lower():
problems.append("nosnippet set: no text snippet will be shown")
return problems
sample = """<html><head>
<meta name="description" content="Shoes.">
<meta name="robots" content="nosnippet">
</head><body></body></html>"""
for problem in check(sample):
print(problem)Running it prints two lines: one for the short description and one for nosnippet.
Why a snippet differs from your description
When the snippet is not your description, the cause is usually one of these.
- The query matched body text better. The description does not contain the words the user searched for, so the engine chose a passage that does.
- The description is too generic. Identical or boilerplate descriptions across many pages give the engine no reason to prefer them.
- The description is misleading or stuffed with keywords. Engines compare it with the visible content and discard it if it does not summarize the page.
- The tag is not readable. It sits outside the
head, is duplicated with conflicting values, or is generated by JavaScript that the crawler did not run. - A robots directive applies.
max-snippetmay be cutting the text shorter than you expect.
Compare the snippet to the page by searching for a query close to the page's main topic, then for a narrow phrase from deep in the body. If the first shows your description and the second shows body text, the system is working as designed.
Practical guidance
- Write the description as a summary of what the page offers, with the main topic in the first 100 or so characters.
- Make each paragraph under a heading understandable on its own, because that is the unit engines extract.
- Give every page its own description. Where that is not possible, for example on thousands of generated pages, omit the tag and rely on body text instead of repeating one string.
- Use
max-snippetanddata-nosnippetfor specific business or legal reasons, not as routine settings. - Expect variation. Check a handful of real queries, but do not treat one different snippet as an error.
Exercise
Your product page has a unique, accurate meta description of 140 characters. A search for a very specific phrase shows a different sentence from the middle of the page as the snippet. Is something wrong, and what could you change if you wanted that sentence to appear?
Show answer
Nothing is wrong. Snippets are chosen per query, and the engine used body text because it matched the specific phrase better than the description. If you want that content to appear for such queries, make sure the sentence is visible HTML text, is not inside a data-nosnippet element, is not blocked by a small max-snippet value, and reads clearly on its own.
Exercise
A page includes the robots meta tag content="max-snippet:0". What effect does it have on the text snippet, and does it change how the page ranks?
Show answer
max-snippet:0 behaves like nosnippet, so no text snippet is shown for the page. It controls display only and is not a ranking signal, although a result without a snippet may receive fewer clicks.