Structured data: microdata & JSON-LD
6 min lesson
- Structured data is a standard way to label the details of a page, such as a product's price or a recipe's cooking time.
- Search engines use it to show rich results, like star ratings and prices directly in search.
- Microdata adds itemscope and itemprop attributes inside HTML; JSON-LD puts the same data in a script tag as a JSON object.
- Think of structured data as a filled form about the page, written in a language search engines already know.
- JSON-LD is recommended because it is separate from the visible HTML and easier to maintain.
- This builds on SEO & meta tags: those describe the page broadly; structured data describes specific facts.
- The example uses JSON-LD to describe a recipe; you will not see changes on the page, but search engines read the data.
- Next, Responsive design & the viewport meta tag returns to layout for all screen sizes.
- Use JSON-LD in a script tag for the simplest structured data.
- Match the data to what is visible on the page; hidden or wrong data is a violation.
- Use the official schema.org vocabulary for names like Recipe or Product.
- Test with a structured data testing tool before publishing.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Structured data</title>
<!-- JSON-LD describes the page for search engines -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Recipe",
"name": "Simple bread",
"cookTime": "PT45M",
"recipeIngredient": ["Flour", "Water", "Yeast"]
}
</script>
</head>
<body>
<!-- Visible content that matches the structured data -->
<h1>Simple bread</h1>
<p>Cooking time: 45 minutes.</p>
<p>Ingredients: Flour, Water, Yeast.</p>
</body>
</html>What happens: A page showing the heading "Simple bread", the paragraph "Cooking time: 45 minutes." and the paragraph "Ingredients: Flour, Water, Yeast." The JSON-LD is not visible to users but is read by search engines.
Breaking it down
@context
"@context": "https://schema.org"Tells the search engine which vocabulary you are using. schema.org is the standard one.
@type
"@type": "Recipe"Says what kind of thing this is, so the search engine knows which fields apply.
name
"name": "Simple bread"The title of the thing. It must match the visible heading on the page.
cookTime
"cookTime": "PT45M"A duration in ISO 8601 format: P for period, T for time, 45M means 45 minutes.
Common schema types
| Type | Used for |
|---|---|
| Recipe | Food recipes and cooking times |
| Product | Prices, availability, reviews |
| Article | Blog posts and news |
| Person | People and their details |
| Organization | Company name and logo |
A helpful analogy
Structured data is like a nutrition label on a food package: the same information is inside the food, but the label puts it in standard boxes so anyone can compare products quickly.
Nesting rules
- 1.Put the JSON-LD script inside head or body, but keep the JSON valid.
- 2.Use one script per type to keep things readable.
Common mistakes
Adding data that is not visible on the page
Avoid
A rating of 5 stars in JSON-LD with no review shownUse instead
Show the review and the same rating on the pageSearch engines treat hidden structured data as misleading and may penalize the page.
Invalid JSON inside the script
Avoid
{ "@type": "Recipe", }Use instead
{ "@type": "Recipe" }A trailing comma breaks the JSON, and the whole block is ignored silently.
Quick tips
- •Run your page through a structured data testing tool to check for errors.
- •Start with one type, like Article or Recipe, and expand only when needed.