Automated technical SEO checks that catch indexing blocks and deploy regressions — seotto.com

Headings are the outline of a page. Screen-reader users jump between them. Search engines use them, along with the title and the body text, to understand what a page covers and where one topic ends and the next begins. And they are one of the easiest things to get quietly wrong on a site that is built from components.

A design system that renders <h3> because it looks right, a card component that wraps every title in <h2>, a hero banner with the page title in a <div>: none of these throw an error. They produce pages whose outline makes no sense, and nobody notices until an audit.

An audit is a small script. Here is one.

What to look for

There is no ruling that says "exactly one <h1>". Google has said that multiple <h1> elements are not a problem, and HTML5 allows them. But most sites that have several are accidents. These are the patterns worth reporting:

  1. No <h1> at all. Often the page title lives in a styled <div> or <p>.
  2. Several <h1> elements. Frequently a logo, the page title and a promotional banner all use it.
  3. Skipped levels. An <h2> followed directly by an <h4>. That breaks the outline for assistive technology.
  4. Empty headings. <h2></h2> or one that contains only an icon or whitespace.
  5. Headings that duplicate the title exactly, in every page. A site-wide <h2>Subscribe to our newsletter</h2> in the footer is noise in an outline.
  6. The first heading is not an <h1>. A page that starts with an <h3> has a structural problem.

The script

#!/usr/bin/env python3 """usage: python3 headings.py https://example.com/sitemap.xml > headings.csv""" import csv import sys import xml.etree.ElementTree as ET from collections import Counter import requests from bs4 import BeautifulSoup HEADERS = {"User-Agent": "Mozilla/5.0 (compatible; heading-audit/1.0)"} NS = {"sm": "http://www.sitemaps.org/schemas/sitemap/0.9"} def sitemap_urls(url): root = ET.fromstring(requests.get(url, headers=HEADERS, timeout=30).content) if root.tag.endswith("sitemapindex"): for loc in root.findall("sm:sitemap/sm:loc", NS): yield from sitemap_urls(loc.text.strip()) else: for loc in root.findall("sm:url/sm:loc", NS): yield loc.text.strip() def audit(url): r = requests.get(url, headers=HEADERS, timeout=30) soup = BeautifulSoup(r.text, "html.parser") heads = [(int(h.name[1]), " ".join(h.get_text().split())) for h in soup.find_all(["h1", "h2", "h3", "h4", "h5", "h6"])] issues = [] levels = [lvl for lvl, _ in heads] if not levels.count(1): issues.append("no-h1") if levels.count(1) > 1: issues.append(f"multiple-h1({levels.count(1)})") if levels and levels[0] != 1: issues.append(f"starts-with-h{levels[0]}") for prev, cur in zip(levels, levels[1:]): if cur - prev > 1: issues.append(f"skip-h{prev}-to-h{cur}") break if any(not text for _, text in heads): issues.append("empty-heading") return r.status_code, len(heads), issues, heads if __name__ == "__main__": out = csv.writer(sys.stdout) out.writerow(["url", "status", "headings", "issues", "first_h1"]) footer_text = Counter() rows = [] for u in sitemap_urls(sys.argv[1]): status, n, issues, heads = audit(u) h1 = next((t for l, t in heads if l == 1), "") for l, t in heads: if l >= 2: footer_text[t] += 1 rows.append((u, status, n, issues, h1)) for u, status, n, issues, h1 in rows: out.writerow([u, status, n, ";".join(issues), h1]) # headings repeated on many pages are usually site chrome, not content for text, count in footer_text.most_common(5): if count > len(rows) * 0.5: print(f"# repeated on {count} pages: {text!r}", file=sys.stderr) 

It reads every URL in your sitemap, follows an index file if you have one, and writes one row per page. Install the two dependencies with pip install requests beautifulsoup4, and add a short time.sleep(0.2) inside the loop if the site is small or slow.

Reading the output

Sort the CSV by issues and look at the shape of the problem, not the count. A thousand pages with multiple-h1(2) is one template bug. Twelve pages with no-h1 is twelve editors who used a different layout. Template bugs are worth fixing first, because one change repairs every page that uses the template.

python3 headings.py https://example.com/sitemap.xml > headings.csv cut -d, -f4 headings.csv | sort | uniq -c | sort -rn | head 

The last command gives you a ranking of issue types across the site.

Raw HTML versus rendered HTML

The script reads the HTML that the server sends. If your site builds its headings in JavaScript, the page you see in a browser has headings that this script cannot see, and a crawler that does not render may not see them either. I wrote about that gap in view source versus Inspect element. If your results show no-h1 on pages that clearly have one, that is the likely cause, and it is worth knowing about on its own. For those pages, run the same checks in a headless browser instead.

Fixing what you find

  • Choose the semantic level, then style it. A heading's level describes the outline, and its size is a CSS concern. If a card title should look small, give it a class, not a different tag.
  • Make the page title the <h1>, once, in the main content. Not the logo. Not a banner. If the logo is a link, it is a link.
  • Never skip a level to get a look. Go from <h2> to <h3>, even if you want text that looks like <h4>.
  • Remove headings that are decoration. A "Related", "Share" or "Newsletter" block in the footer does not need to be an <h2> in a document outline. Use a <p> or a <div> with aria-label.
  • Fix it in the component, not in the page. If your design system hard-codes a tag for a card title, add a prop for the level.

Headings that were right when you shipped them can drift after a template change. seotto.com runs automated technical SEO checks on a schedule, so a deploy that drops the page title from the markup or duplicates it shows up as a regression in a report, not a drop in rankings.

Make it a check, not a project

A one-time audit finds today's problems, and the next redesign recreates them. Add the same logic to your CI as a test against a few representative URLs: one article, one product, one listing, the homepage. Fail the build if any of them has no <h1> or skips a level. It is a dozen lines, and it protects every future change to the layout.

Titles and descriptions belong in the same family of checks, and I covered those in finding duplicate and missing title tags with a Python crawl script. If you want a broader guard against template changes, diffing titles, canonicals and robots tags between deploys extends the idea to a whole release.

Related reading

Do you audit heading structure, or do you trust the design system? What is the strangest heading you have found in a production template?