Sub topic 12
Audit and Test Your Page Structure
Assume you know basic HTML and understand how search engines display results. This chapter shows how to test whether a page has a clear structure that retrieval-based AI answer systems can use. An audit cannot guarantee citation, but it can find structural problems that make useful passages harder to identify.
What should a structure audit check?
A structure audit checks the page’s outline, section content, semantic elements, and structured data. Start with these questions:
- Does the page have exactly one main
h1? - Do headings follow the order
h1,h2,h3without unexplained jumps? - Does each heading describe the answer or information below it?
- Does each section make sense when read by itself?
- Do lists represent steps, options, or requirements?
- Do tables compare the same attributes across rows?
- Does JSON-LD repeat visible content accurately?
AI systems often retrieve passages rather than entire pages. A heading and its nearby paragraph give a retrieved passage context. A vague heading, an empty section, or a table without labels gives the system less reliable context.
How do you test the heading outline automatically?
A small script can detect multiple h1 elements, skipped heading levels, and empty headings. These checks catch structural errors without judging whether the wording is useful.
from html.parser import HTMLParser
class HeadingAudit(HTMLParser):
def __init__(self):
super().__init__()
self.headings = []
self.current_level = None
self.current_text = []
def handle_starttag(self, tag, attrs):
if len(tag) == 2 and tag[0] == "h" and tag[1].isdigit():
level = int(tag[1])
if 1 <= level <= 6:
self.current_level = level
self.current_text = []
def handle_data(self, data):
if self.current_level is not None:
self.current_text.append(data)
def handle_endtag(self, tag):
if self.current_level is None:
return
expected = f"h{self.current_level}"
if tag == expected:
text = " ".join("".join(self.current_text).split())
self.headings.append((self.current_level, text))
self.current_level = None
self.current_text = []
def audit(html):
parser = HeadingAudit()
parser.feed(html)
errors = []
h1_count = sum(level == 1 for level, _ in parser.headings)
if h1_count != 1:
errors.append(f"Expected one h1, found {h1_count}")
for level, text in parser.headings:
if not text:
errors.append(f"Empty h{level} heading")
for previous, current in zip(parser.headings, parser.headings[1:]):
if current[0] > previous[0] + 1:
errors.append(
f"Skipped from h{previous[0]} to h{current[0]}: "
f"{current[1]!r}"
)
return parser.headings, errors
html = """
<h1>Router troubleshooting</h1>
<h2>Why is the router offline?</h2>
<h3>Check the cable</h3>
<h2>When should you restart it?</h2>
"""
headings, errors = audit(html)
print("Headings:", headings)
print("Errors:", errors)The script checks levels, not meaning. For example, h2 headings named “More” may pass the script but still fail a manual review. Run the audit against the rendered HTML if a framework generates headings dynamically.
What should you review manually?
After automated checks pass, inspect the page as a reader and as a retrieval system. Read each section’s heading and first paragraph without the rest of the page. The answer should remain understandable. Replace pronouns such as “this” or “they” when the referenced subject may be missing from a retrieved passage.
Check that the element matches the information:
| Content type | Suitable structure | Audit question |
|---|---|---|
| A sequence of actions | Ordered list | Does the order affect the result? |
| Alternatives or requirements | Unordered list | Is there no required order? |
| Repeated attributes | Data table | Does every column have a clear header? |
| Explanation or qualification | Paragraphs | Can the reader follow the subject and scope? |
For tables, confirm that the caption states the table’s purpose and that header cells identify each row or column. For lists, confirm that each item has a similar grammatical shape. Do not use visual indentation alone to imitate a list.
How do you test structured data?
Compare every JSON-LD answer with the visible page. Remove or update structured data when the visible wording changes. Structured data can clarify entities and page types, but it does not force an AI system to quote the page. Treat it as supporting metadata, not a citation guarantee.
What common audit failures look like
Typical failures include:
- An
h1followed directly byh3because the author chose a visual size instead of a level. - Several sections beginning with “It depends” without naming the subject.
- A table used for page layout instead of data.
- A list containing long unrelated paragraphs.
- FAQ JSON-LD containing answers that are absent from the page.
- A heading that promises a comparison while the section discusses only one option.
Fix the source structure rather than adding keywords or hidden text. Then rerun the automated check and repeat the manual passage review.
Exercise
A page has one h1, then h3, followed by h2. Its JSON-LD contains an answer that does not appear in the visible page. What should you fix first?
Show answer
Change the h3 to the correct level, then remove or update the JSON-LD so it matches visible content. Rerun the script and review the affected sections manually.