A static directory built from a Google Maps export can generate hundreds or thousands of pages in one run. Most of them come out fine. A few come out wrong in ways that are easy to miss by clicking around: a city page with zero listings, a category link pointing to a slug that no longer exists, a phone link with a stray character that stops the dialer from opening.
You can catch most of these with a handful of checks that run after every build and before every deploy. None of them need a browser or a testing framework. They read the output folder, count things and fail loudly when the counts look wrong. This article walks through the checks worth writing and how to keep them useful as the site grows.
Treat the build folder as test data
The output of a static build is a folder of HTML files, a sitemap and maybe a search index in JSON. That folder is a perfect test fixture. It is the exact thing that will be served, and it does not change while you inspect it.
Write your checks as a script that takes the folder path as an argument and exits with a non-zero code on failure. That way the same script runs on your laptop, in a CI job or as a step in a deploy script. Keep the checks independent of how the site was generated, so they still work if you switch generators later.
Check that every page has content
The most common silent failure is an empty page. A city where every listing was filtered out still gets a page, with a heading, a map and nothing else. Visitors land on it from search and leave immediately.
Parse each city and category page and count the listing cards. Fail the build if any page has zero. Warn if a page has fewer than some small threshold you choose, since a page with one listing may be fine or may point to a filtering mistake upstream. Here is a minimal version in Python using only the standard library:
import pathlib, re, sys
root = pathlib.Path(sys.argv[1])
bad = []
for page in root.rglob("index.html"):
cards = len(re.findall(r'class="listing-card', page.read_text()))
if "/city/" in str(page) and cards == 0:
bad.append(str(page.relative_to(root)))
if bad:
print("Empty city pages:", *bad, sep="\n ")
sys.exit(1)
Adjust the class name and path pattern to match your templates. A regex is fine here because you control the HTML. If you do not, use a real parser.
Check internal links resolve
Directory sites are dense with internal links: city to category, category to listing, breadcrumbs, nearby cities. When a slug changes or a page gets dropped, links to it break across the whole site.
Collect every href that points inside the site, normalize it to a file path, and confirm the file exists. Count failures per target rather than per link, since one missing page can produce hundreds of broken links and you only need to fix it once. This check runs in seconds even on large sites because it never touches the network.
Check the contact data that visitors click
Phone and website links are the most valuable clicks on a directory, and the easiest to break with dirty data. For phone links, confirm that every tel: href contains only digits and an optional leading plus sign. For website links, confirm each one parses as a URL with an http or https scheme and a hostname.
You do not need to fetch every external site on every build. A weekly job that requests each business website and records the status code is a better fit, because external sites go down and come back on their own schedule. Keep the results in a file and compare week to week.
Check the sitemap matches the pages
Two quick comparisons catch most sitemap mistakes. Every URL in sitemap.xml should map to a file in the build folder. And every city and category page in the build folder should appear in the sitemap. Pages missing from the sitemap are easy to forget, and pages in the sitemap that do not exist will show up as errors in Search Console later.
While you are there, compare the page count to the previous build. A drop of more than a few percent usually means something went wrong in the data step, and it is better to find out before deploying than after. If you want a broader picture of measuring a directory beyond build checks, there are notes on testing and measuring directory sites that cover what happens after launch.
Keep the checks honest over time
Checks that cry wolf get ignored. When a check fails for a reason you decide is acceptable, change the rule rather than skipping it. Write the threshold into the script with a comment explaining why it is set where it is.
Keep the list short. Five checks that always run beat twenty that are slow and flaky. For the manual side of the same process, this list on how to check a static directory build before you upload it covers what is still worth doing by hand on a phone.
The same checks apply whether you write your own generator or use a tool such as 1 Click Directory Builder, which turns a Google Maps export into a complete static directory site.
Questions about build-time checks
Should these checks block a deploy?
Empty pages and broken internal links should block it, since they are always mistakes. Thresholds like page count drops can warn first and block later, once you trust the numbers.
How long should the checks take?
On a site with a few thousand pages, all of the offline checks above should finish in well under a minute on an ordinary laptop. If they take longer, look for repeated file reads.
Do I still need Lighthouse or browser tests?
For layout and performance, yes. Build checks catch data and link problems. Browser tools catch rendering and speed problems. They complement each other.
Top comments (0)