DEV Community

One page, four addresses: the SEO bugs your browser can't show you

I audited a site I built last week. Fifty-four pages, mostly hand-written HTML, deployed on Cloudflare. I ran Lighthouse first, got a number I was happy with, and closed it. Then I opened a terminal and pulled the raw HTML of a single page. That is where the evening went sideways.

The page had a canonical tag pointing at /blog-chinese-tones. The JSON-LD block on the same page pointed at /blog-chinese-tones.html. The breadcrumb pointed at /index.html. Three spellings of one URL, inside one document, each one claiming to be the address of the thing.

DevTools doesn't flag it. Lighthouse doesn't flag it. The page renders, it scores well, it looks finished. But a crawler doesn't look at the page. It looks at four separate descriptions of the page. When those four disagree, the page stops being one page.

Everything below is what those four descriptions are, and the four bugs I found by comparing them.

The four descriptions

  • The rendered DOM. What you see. After JavaScript runs.
  • The raw HTML. What most crawlers see. Before JavaScript, or without it entirely.
  • The structured data. JSON-LD, embedded in that HTML, saying what the page is.
  • The URL itself, in whatever spelling your canonical tag, sitemap, and hreflang links chose.

DevTools shows you the first one. curl shows you the second. A JSON parser shows you the third. The fourth is scattered across a <link> tag and two XML files that nobody opens at the same time as the page.

I wrote a script that pulls all four and compares them. Then I ran it on every URL in the sitemap.

Bug 1: 91 URLs that disagree with their own canonical

Nineteen pages had JSON-LD blocks containing URLs that ended in .html. Every one of those pages had a canonical tag without the extension. The breadcrumb items on a few pages pointed at /index.html and /blog.html, which are not pages that exist.

Here is the actual shape of it:

Where the URL was written Spelling Count
<link rel="canonical"> /blog-chinese-tones 1 per page
JSON-LD @id, url, mainEntityOfPage /blog-chinese-tones.html 91 total
Breadcrumb item /index.html 19 pages

The cause is boring and worth writing down. The files on disk are literally named blog-chinese-tones.html. When I hand-wrote the schema, I copied the filename. Six weeks later I decided to strip extensions from canonical URLs. I updated the canonical tags and the sitemap. I did not remember the schema blocks existed.

That is the shape of this whole class of bug. Not carelessness. Two decisions made weeks apart, with no single source of truth between them.

Why it matters more than it looks: search engines use the URL as an entity ID. Two spellings mean two nodes in the graph, and the signals attached to each one stay split. Schema.org has an @id field for exactly this reason, to give a thing one name. I gave it two.

AI retrieval pipelines are less forgiving, because they merge sources by URL when they assemble an answer. Two addresses read as two sources, one of which is thinner than it should be.

The fix took half an hour: one string replacement across 54 pages. But the fix that actually holds is generating the canonical URL once at build time and having the schema read from that same variable. Otherwise the next person to touch it, which will be me, repeats the mistake.

Bug 2: a static site with no cache at all

curl -sI https://thechinesepath.com/chinese-tones | grep -iE 'cache-control|cf-cache'
cache-control: public, max-age=0, must-revalidate
cf-cache-status: DYNAMIC

DYNAMIC from Cloudflare means it is not caching this. Not the edge, not the browser. Every request goes back to the origin, and the origin regenerates a page that has not changed since the last deploy.

I set it that way on purpose, and the reason was good enough at the time: max-age=0 means I see my changes the moment I deploy. No stale-page confusion, no purge step to remember. The cost is paid by someone else. Every crawler, every fetch, every retry crosses an ocean to read the same bytes.

I measured one of these on a bad link: a 95KB page, forty seconds, not finished. Crawlers don't wait that long. They have a per-host budget and they spend it on whatever answers. A page that times out isn't a page with a slow load time. From the crawler's side it's a page that doesn't exist.

The correct trade isn't to turn caching off. It's to cache at the edge and purge on deploy:

Cache Rule: thechinesepath.com/*
Edge TTL: 4 hours
Browser TTL: 10 minutes
stale-while-revalidate: on

or, from the origin:

Cache-Control: public, s-maxage=14400, stale-while-revalidate=86400

Same freshness guarantee for me, because deploy triggers the purge. Completely different experience for anything crawling the site.

Bug 3: 136KB of HTML, 1,960 characters of prose

One page, a library of 642 character cards, is the most citable content on the site. It weighs 136KB. Strip the tags and 1,960 characters of visible text remain.

The cards live in a JavaScript array. A browser runs the array and draws 642 cards. GPTBot, ClaudeBot, and PerplexityBot fetch the raw HTML and see a heading that says "642 cards" followed by a stack of empty containers. The content exists. It has existed for weeks. It is simply stored somewhere the reader can't reach.

The fix isn't an SEO technique, it's a relocation. Render the list at build time as a four-column table, hanzi, pinyin, English, level. Let JavaScript add filtering and audio on top. 642 table rows is close to the ideal shape for something that gets excerpted into an answer, and it also makes the page faster for people, because a table is cheaper than 642 DOM nodes built at runtime.

Worth noting how easy this one is to miss. You open the page, you see the cards, you assume they're there. They are there for you. "It renders" and "it exists" are different claims, and only one of them is visible in a browser.

Bug 4: a sameAs pointing at nobody

Article authorship was set to an Organization. No name, no author page, no external account anywhere. For a site whose entire value is "a native speaker explaining Chinese," that's a strange thing to leave blank.

I fixed the on-site half: an /about page, Article.author as a Person, a byline and author card on twelve posts, Organization.founder pointing at the same node, and sameAs pointing at a GitHub profile.

The off-site half is still broken. That GitHub account was registered two weeks ago. No bio. No website field. Zero followers. Two repositories, both forks of other people's lists. sameAs is not a statement about yourself. It's a claim that two things are the same entity, and a claim only counts when the other side agrees.

Right now the site says "this person is that GitHub account" and the GitHub account says nothing at all. In entity resolution, a one-sided link is close to noise.

This is the least mechanical bug of the four and the one most likely to be skipped, because fixing it isn't a code change. It's writing down who you are, in a place you don't control, and then linking back.

These four are one bug

Look at them together. A page whose schema contradicts its canonical. A static file that gets rebuilt for every visitor. Content that exists only after JavaScript. A person identity that stops at the domain boundary. None of it is broken code.

In every case a fact about the page was written down twice, in two places, and one copy went stale. The page is fine. The record of the page disagrees with itself.

That's why no tool caught it. Lighthouse evaluates the rendered page against a fixed rule set, and "your schema URL should equal your canonical URL" isn't in that rule set, because it isn't a standard anyone wrote down. Your framework doesn't check it either. Your build passes. Everything that looks at one description of the page reports success.

The only thing that finds this class of bug is comparing the descriptions to each other. Which nobody does, because they live in four different tools.

Run it on your own site

Here is the check, stripped to the part that matters. It fetches one URL, pulls the canonical, walks every JSON-LD block, and prints any URL in the structured data that points at this page under a different spelling.

My first version was dumber than that. It compared every URL in the JSON-LD against the canonical and reported six mismatches on a page that was actually correct. All six were fragment identifiers, #article and #organization, plus references to /about and /. Those are legal schema. A page is allowed to point at other nodes. So the comparison needs two questions, not one. Does this URL refer to the page I'm checking? And if so, did it spell the address the same way?

import json, re, sys, urllib.request

def fetch(url):
    req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
    return urllib.request.urlopen(req, timeout=20).read().decode("utf-8", "replace")

def urls_in_jsonld(html):
    blocks = re.findall(r'<script[^>]*type=["\']application/ld\+json["\'][^>]*>(.*?)</script>', html, re.S)
    found = set()
    for block in blocks:
        try:
            data = json.loads(block)
        except Exception:
            continue
        stack = [data]
        while stack:
            node = stack.pop()
            if isinstance(node, dict):
                for key, val in node.items():
                    if key in ("@id", "url", "item", "mainEntityOfPage") \
                        and isinstance(val, str):
                        found.add(val)
                    elif isinstance(val, (dict, list)):
                        stack.append(val)
            elif isinstance(node, list):
                stack.extend(node)
    return found

def raw(u):
    # drop the #fragment and any trailing slash, keep the extension
    return re.sub(r'[#?].*$', '', u).rstrip('/')

def core(u):
    return re.sub(r'\.html?$', '', raw(u))

def main(url):
    html = fetch(url)
    tag = re.search(r'<link[^>]*rel=["\']canonical["\'][^>]*>', html, re.I)
    href = re.search(r'href=["\']([^"\']+)["\']', tag.group(0)) if tag else None
    canonical = href.group(1) if href else None
    found = urls_in_jsonld(html)
    print("canonical:", canonical)
    print("urls in JSON-LD:", len(found))
    if not canonical:
        print("no canonical tag found")
        return
    bad = sorted(u for u in found if u.startswith("http") and core(u) == core(canonical) # same page
        and raw(u) != raw(canonical)) # spelled differently
    if bad:
        print("\nmismatched:")
        for u in bad:
            print("", u)
    else:
        print("every URL agrees with the canonical")

if __name__ == "__main__":
    main(sys.argv[1])

Two minutes to run against a sitemap. The output is either "every URL agrees" or a list of strings that don't match, and both answers are unambiguous.

What I can't tell you

I have no clean before-and-after for any of this. The site is small, the indexing numbers are small, and at that scale a change of a few dozen impressions is noise. Bing impressions going from 7 to 25 across a month is not evidence of anything, and I'm not going to pretend it is.

What I can tell you is that the schema/canonical mismatch isn't a hypothesis. It's a string comparison. It was 91 strings, and now it's zero. Whether that moves a ranking is a question I'll answer in six months with more data than I have today.

Most SEO advice sits in the first category, plausible correlation. A small amount of it sits in the second, verifiable fact. The verifiable ones are cheaper to fix and don't require you to trust anyone, so they should probably go first.

Run the script on one page. If the URLs agree, close the tab and get back to work. If they don't, you found a bug that no dashboard was ever going to report, on a page that has been describing itself two ways, possibly for months. That one fits before lunch.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.