How Does a URL Work?
URLs are to web pages what physical addresses are to homes and businesses.
And just like a physical address contains multiple elements of information (both mandatory and optional) that identify a specific physical location (e.g. country, city, street address, unit number, postal code, etc.), URLs are made up of different parts that tell your web browser where and how to access a resource or web page hosted on the web.
Six Parts of a URL
Protocol/Scheme
The first part of a URL is known as its scheme. The scheme specifies which communication protocol your web browser should use to request the resource. Virtually all websites today use the HTTP or HTTPS protocols, but URLs may also reference the FTP protocol (used to download files), mailto protocol (used to send email) and other schemes.
Host/Domain Name
After the schema in any URL, you’ll see the domain name. Every domain name ends with a top-level domain (TLD), such as .com, .org, or .net, or a country-code top-level domain (ccTLD) like .ca, .uk, or .tv.
The domain names purchased by brands from domain name registrars are subdomains under the specified TLD, also known as second level domains. Some URLs include “www.”, a third-level domain indicating that the domain is part of the world wide web.
Port
Every URL specifies a port that should be used to complete the connection. Ports are not always visible in the URLs that appear in your web browser, but they are required. Port 80 is the default port for web servers.
File Path
Following the domain name and the port, the next part of a URL is the file path. A file path indicates the exact location of the desired resource in the website’s file structure, with references to directories and subdirectories separated by a forward slash.
Some URLs display an asset file extension (e.g. .html, .png, ,jpeg, etc.) that indicates the type of resource being accessed, but many webmasters omit the asset file extension to keep their URLs short and elegant.
Parameters
Any portion of a URL that follows a question mark is known as a parameter. A URL may contain just one parameter, or multiple parameters separated by an ampersand character. URL parameters can be used for a variety of purposes, including:
- Tracking user session data with UTM parameters using Google Tag Manager,
- Sorting, filtering, or identifying items that appear in search results or product listings on a page,
- Pagination, or
- Temporarily translating a page into another language,
Fragments
The portion of a URL that appears after an octothorpe (AKA a hashtag, or “#”) is known as a fragment. In this case, the octothorpe is known as a “fragment identifier”. Fragments are internal page references that instruct your web browser to scroll to a specific “bookmarked” location within the content that appears on the page.
Every URL includes a scheme, a domain name, and a port – although the scheme, port, and third-level domain (www) may be hidden in your browser’s address bar. A file path is also mandatory when the URL points to a resource outside the home page. Parameters and Fragments are optional components that can be implemented at your discretion.