Sub topic 8
Marking Up Ranked Lists with `schema.org` `ItemList`
This chapter assumes you know basic HTML, how search crawlers read pages, and the basics of JSON. You will add structured data to a ranked product list and keep it consistent with the content people see.
What `ItemList` describes
ItemList is a schema.org type for an ordered collection of items. It can describe a list of products, articles, restaurants, or other entities. Each entry is a ListItem with a position.
For a best-of page, the markup should express:
- The name of the list.
- The list position of each product.
- The product name.
- A stable URL for the product's section or page.
The markup gives machines a clear representation of the ranking. It does not guarantee that an AI assistant will retrieve, cite, or recommend the page. Retrieval also depends on crawl access, page quality, evidence, relevance, and the assistant's source-selection process.
| Property | Purpose | Example |
|---|---|---|
| `@type` | Identifies the schema type | `ItemList` |
| `itemListElement` | Contains the ranked entries | An array of `ListItem` objects |
| `position` | States the item's rank | `1` |
| `url` | Points to the described item | `/best-project-tools#tool-a` |
Match the markup to the visible list
Suppose the page visibly ranks Tool A first and Tool B second. The JSON-LD should use the same order, names, and links:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Best project management tools for small teams</title>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "ItemList",
"name": "Best project management tools for small teams",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Tool A",
"url": "https://example.com/best-project-tools#tool-a"
},
{
"@type": "ListItem",
"position": 2,
"name": "Tool B",
"url": "https://example.com/best-project-tools#tool-b"
}
]
}
</script>
</head>
<body>
<main>
<h1>Best project management tools for small teams</h1>
<ol>
<li id="tool-a">
<h2>Tool A</h2>
<p>Best for simple task boards.</p>
</li>
<li id="tool-b">
<h2>Tool B</h2>
<p>Best for teams that need timelines.</p>
</li>
</ol>
</main>
</body>
</html>The ordered HTML list is important. It gives readers and assistive technology the ranking directly. JSON-LD describes that same information for software. Do not put products in structured data that are hidden from the page or use different names from the visible headings.
Validate positions and links
Positions should normally run from 1 through the number of entries without duplicates or gaps. Anchors should resolve to the relevant section. A small automated check can catch accidental changes during editing:
import json
import re
import sys
html = open(sys.argv[1], encoding="utf-8").read()
blocks = re.findall(
r'<script type="application/ld\+json">(.*?)</script>',
html,
re.S,
)
for raw in blocks:
data = json.loads(raw)
if data.get("@type") != "ItemList":
continue
entries = data["itemListElement"]
positions = [entry["position"] for entry in entries]
expected = list(range(1, len(entries) + 1))
assert positions == expected, f"Invalid positions: {positions}"
print(f"ItemList is valid: {len(entries)} entries")Run it with the saved HTML file as its argument. Add checks for duplicate URLs, empty names, and links that do not appear in the visible page.
A simple publishing workflow
Exercise
Exercise
The visible page ranks Tool B first, but the JSON-LD gives Tool A position 1. What should you change?
Show answer
Correct the JSON-LD to match the visible ranking, or change the visible ranking if the editorial decision was wrong. Then validate positions, names, and URLs again.