Links Gorilla · Article · 6 min read

The Anatomy of a URL

A URL looks like a single string, but it's actually a structured address with up to six distinct parts. Once you can spot them, debugging and writing URLs becomes much easier.

Protocol (or scheme)

The protocol is everything before the colon and two slashes — usually https:// today, sometimes http://, mailto:, tel:, or ftp://.

It tells the browser how to talk to the server. https means an encrypted connection; http means plain text and is no longer recommended for anything beyond local development.

Host and port

The host is the domain name (example.com) or IP address that identifies the server. Optional subdomains like www. or blog. sit in front of it.

An optional port number can follow a colon — for example example.com:8080. Standard ports (80 for http, 443 for https) are implied and never written.

Path

The path comes after the host and looks like /products/laptops. It identifies the specific resource on the server — a page, an API endpoint, a file.

Paths read like folders, but on modern sites they're usually handled by routing code, not actual directories on disk.

Query string

Everything after the ? is the query string: ?utm_source=newsletter&page=2. It carries key=value pairs joined by &.

Query parameters are how URLs pass extra context — search terms, filters, tracking codes — without changing the underlying page.

Fragment (the hash)

Everything after # is the fragment. It's handled by the browser, not the server, and is typically used to scroll to a section on the page (#faq) or to store client-side state in single-page apps.

Frequently asked questions

Only the protocol and host are strictly required. Path, query, and fragment are optional.