Every resource on the internet — every page, image, file or API endpoint — has a unique address called a URL. Understanding the structure of a URL helps you navigate the web, troubleshoot issues and build better websites.
Quick answer: A URL (Uniform Resource Locator) is the complete address of a resource on the internet. It consists of a protocol (
https://), domain name, optional path, optional query string and optional fragment. Example: https://example.com/articles/guide?lang=en#section1
Anatomy of a URL
Let's break down a full URL:
https://www.example.com:443/articles/guide?lang=en&page=2#summary
- Protocol —
https://— Defines how data is transferred.httpsis encrypted,httpis not. - Subdomain —
www— Optional. Most sites usewwwor none at all. - Domain —
example.com— The website's registered domain name. - Port —
:443— Usually omitted. Default is 443 for HTTPS and 80 for HTTP. - Path —
/articles/guide— Identifies the specific page or resource on the server. - Query string —
?lang=en&page=2— Optional parameters passed to the server, starting with?. Multiple parameters separated by&. - Fragment —
#summary— Jumps to a specific section on the page. Processed by the browser, not sent to the server.
URL vs URI vs URN
- URL (Uniform Resource Locator) — Specifies location:
https://example.com/page - URI (Uniform Resource Identifier) — Broader term that includes URLs
- URN (Uniform Resource Name) — Identifies by name without location:
urn:isbn:0-486-27557-4
In everyday use, URL and URI are used interchangeably.
Best Practices for URL Structure
- Use lowercase letters only
- Use hyphens (
-) to separate words, not underscores (_) - Keep URLs short and descriptive
- Include the target keyword in the path for SEO
- Avoid unnecessary parameters in URLs that should be indexed
- Use canonical URLs to handle duplicate content
Absolute vs Relative URLs
- Absolute URL — Full address including protocol and domain:
https://example.com/about - Relative URL — Path only, relative to the current page:
/aboutor../images/logo.png
Use absolute URLs in canonical tags, sitemaps and external links. Use relative URLs internally to make a site easier to move between environments.