Sub topic 1
How AI answer systems find and quote your content
Prerequisites
This chapter assumes you know basic HTML elements such as headings, paragraphs, lists, and tables. You should also know what a search result looks like. The audit example needs Python 3.
How AI answer systems find and quote your content
Retrieval-based answer systems split a page into passages, score each passage against the user's question, and quote the best matches. Clear structure helps them find where one passage ends and the next begins. A passage that stays on one topic under a clear heading is easier to score and easier to quote without losing its meaning.
Use semantic HTML, not styling, to express structure
Semantic HTML uses tags whose names describe their role. CSS changes how something looks, but a parser reads only the tags. A large bold line made from a div looks like a heading to a reader but carries no structural meaning.
<!-- Looks like a heading, but a parser sees only a styled box -->
<div style="font-size: 2em; font-weight: bold;">Reset steps</div>
<!-- The tag itself says this is a second-level heading -->
<h2>How do I reset the router?</h2>Build a clean heading hierarchy
Use exactly one h1 per page for the title. Nest h2 under it, and h3 under an h2. Do not skip a level, because a jump from h2 to h4 breaks the outline that parsers build.
You can check a page for skipped levels with the standard library:
from html.parser import HTMLParser
class HeadingLevels(HTMLParser):
def __init__(self):
super().__init__()
self.levels = []
def handle_starttag(self, tag, attrs):
if len(tag) == 2 and tag[0] == "h" and tag[1] in "123456":
self.levels.append(int(tag[1]))
def find_skips(levels):
return [
(prev, cur)
for prev, cur in zip(levels, levels[1:])
if cur > prev + 1
]
page = "<h1>Guide</h1><h2>Setup</h2><h4>Power</h4>"
parser = HeadingLevels()
parser.feed(page)
print(parser.levels) # [1, 2, 4]
print(find_skips(parser.levels)) # [(2, 4)]Write headings that describe the section's answer
A descriptive heading states the question the section answers. The first sentence under it should give the answer directly.
| Vague heading | Descriptive heading |
|---|---|
| Details | How long does a factory reset take? |
| Step 3 | Which lights show that the reset worked? |
Exercise
A page has an h1 followed directly by an h3. What should you change, and why?
Show answer
Change the h3 to h2. Parsers and readers expect each heading level to nest under the level above it, and a skipped level breaks the outline.