What reading the URL standard actually gets you

The Web Hypertext Application Working Group, as it turns out, is quite serious about web technologies working the way we all expect them to.

6 minpublished stable

Oliver Byrne, The first six books of the Elements of Euclid (1847), Book I, Proposition XLVII. Public domain.

I read the URL standard to figure out what I would need to do manually to a URL and what I can leave for browsers to figure out when crawling them. I found

Ok, so. The URL standard is the WHATWG document that says how a URL gets parsed. Browsers implement it. Most software that touches HTML follows it. When a link in an href gets turned into something you can actually request, this is the rulebook.1

I went in looking for tactics. Something about canonicals, or duplicates, or how a crawler sees a URL that I didn’t already know. What I came back with was one small tactic, one diagnostic, and a much better idea of where not to spend my attention.

Which honestly is what this kind of reading usually gives you. Less than advertised. Not nothing.

The host gets cleaned up. Properly.

The parser does a lot to the host. It lowercases it. It converts international characters to ASCII (Punycode). It even lays out how to treat IP addresses written in hex and rewrite them into the normal dotted one.

HTTPS://BestDomainEver.COM  →  https://bestdomainever.com/
https://bücher.example      →  https://xn--bcher-kva.example/
http://0x7f.1               →  http://127.0.0.1/

And it can be that aggressive because none of it is the parser’s call. DNS already says hostnames aren’t case sensitive. IDNA already says bücher and xn--bcher-kva are the same name. The parser is just applying rules that were settled somewhere else.

And that’s kind of the point here as well, that understanding even one thing about how the internet works means understanding everything. That’s maybe an overstatement, but it looks good now that I’ve written it down so I’ll keep it.

Everything after the host… barely touched

Past the host it does some housekeeping and that’s it.

  • an empty path becomes a slash, so https://example.com and https://example.com/ are the same URL
  • the default port gets dropped
  • /a/../b gets resolved to /b
  • characters that aren’t allowed get percent encoded

What it never does is decide two different paths are the same page.

/About          ≠  /about
/shoes          ≠  /shoes/
/?a=1&b=2       ≠  /?b=2&a=1
/index.html     ≠  /

All left exactly as written.

And here’s the thing… there’s a reason for that too. What a path means belongs to the server. On one server /About and /about are the same file. On another they’re two files. The parser has no way of knowing which, so it doesn’t guess.

It only merges what it knows is the same.

So where do duplicates actually live?

Put the two halves together. Duplicate URL problems basically never live in the host. They live in the path and the query, the part the parser won’t touch.

There’s one wrinkle. www.example.com and example.com are different hosts, and http and https are different schemes. The parser doesn’t collapse those, so they’re real duplicates. But they’re redirect jobs. You fix them once, sitewide, and they stay fixed.

The path side doesn’t stay fixed. Filters, sorting, tracking parameters, CMS habits, templates. They keep coming back, and every new parameter multiplies them.

Now none of that is news to anyone who’s done a technical audit. I knew parameters caused duplicates. What I didn’t have was the reason. And the reason turns out to be more useful than the list… if the parser leaves something alone because the server might treat it differently, then every variation the server will happily serve is a potential duplicate. You can work them out from how the site is built instead of waiting for a crawl to find them one at a time.

A confession though. For years I gave the host side way more attention than it deserved. The homepage trailing slash especially. Turns out the parser had already solved that one before I ever looked at it.

The one tactic

The host is always lowercased. So BestDomainEver.com and bestdomainever.com are guaranteed to be the same site.

Which means you can write your domain in camel case on a billboard, a business card, a radio ad, the side of a van. It reads better and it costs nothing.

One limit. It stops at the first slash. The path is case sensitive, so BestDomainEver.com/About and BestDomainEver.com/about really are two different pages. Camel case on the domain, nowhere else.

That’s it. That’s the tactic. Small.

And one diagnostic

If you work on a site with accented characters in the domain, sooner or later you’ll see a hostname starting with xn-- in Search Console, or a log file, or a backlink report. That isn’t a second site. It isn’t a scraper. It’s your domain, already converted.

No opportunity there. It just stops you making a dumb call in an audit.

Wrong, but it works

The bit I liked most has nothing to do with tactics.

The standard has two different kinds of problem. A validation error means the input is wrong. You shouldn’t write it… but the parser will still process it. A failure means it can’t be processed at all and nothing comes out.

http://0177.0.0.1/  →  http://127.0.0.1/

A leading zero means octal, so 0177 is 127. That address is a validation error and it resolves fine. Wrong and works at the same time. And the standard says so, on purpose.

I think that gap matters in SEO way more than it gets credit for. Audit tools flag plenty of things that are wrong but work. They miss a few that look fine but fail. Knowing which side of that line an issue sits on is most of triage. The standard draws the line and labels both sides. A lot of best practices lists don’t, and treat “not conforming” like it means “not working”.

Was it worth it?

It didn’t make me better at SEO in any way I could put on a report. No lever. What it did was make me stop looking in one place and start looking in another, and it gave me the reason behind a list I already had.

I’d do it again. I just wouldn’t sell it as more than that.2

Footnotes

  1. WHATWG URL Standard. The parts worth reading are host parsing and URL parsing. Read the parser, not the summaries. ↩

  2. Unless you’re selling a course. Then you need the lever to exist. ↩

first principlesurl standardcanonicalizationepistemics