One URL is a text address that points to a resource, built from scheme, host, path, and optional extras.
URLs look simple, yet small choices decide whether a link works, breaks, or sends people to the wrong place. This guide shows steps to craft valid, readable, and safe links for sites, apps, and files.
What A URL Is
A URL (Uniform Resource Locator) is a type of URI. It tells a browser where to find something and how to fetch it. At a glance you’ll see pieces like the scheme (https), the host (example.com), the path (/docs), and some optional parts.
Make A URL: Step-By-Step
Use this checklist when you need a new link:
- Pick the scheme: https for web pages,
mailto:for email addresses,tel:for phone, ftp only when required by a legacy system. - Choose the host or base: a registered domain or a local name during development.
- Build a clean path: use lowercase letters, digits, and hyphens; avoid spaces and unsafe characters.
- Encode reserved characters: encode spaces as
%20or use hyphens in path names; encode non-ASCII with UTF-8 percent-encoding. - Add a query only when needed: keep keys short and stable; avoid leaking secrets.
- Optionally add a fragment: use it to jump to a section or a client-side state.
- Test the link: try it in more than one browser; check redirects; verify with copy-paste.
URL Parts At A Glance
| Piece | What It Does | Quick Sample |
|---|---|---|
| scheme | Protocol for access | https, mailto, tel |
| host | Domain or address | example.com, localhost, 192.0.2.1 |
| port | Optional network port | :443, :8080 |
| path | Resource location on host | /about, /shop/cart |
| query | Extra data after “?” | ?q=shoes&sort=price |
| fragment | Client-side jump after “#” | #specs, #section-2 |
| userinfo | Optional user:pass@ part | user@example.com |
When To Use A URL Versus Other Identifiers
You’ll see URI, URL, and URN in docs. In practice, “URL” is the everyday label for web addresses, while a URI is the broader class. Standards still guide edge cases; the URI syntax in RFC 3986 spells out the rules used by parsers.
Rules For Characters And Encoding
Start with ASCII letters, digits, and a short set of safe marks. When a needed character is reserved in a part, percent-encode it. Avoid unescaped spaces. Use UTF-8 before encoding any non-ASCII text.
Safe Patterns For Paths
Keep paths readable. Use lowercase words joined with hyphens. Skip underscores in public URLs since they can blur on screens. Keep each segment meaningful. Avoid date-stamped slugs that age quickly unless your CMS requires them.
Domain Choices That Age Well
Pick a domain that matches your brand and is easy to say out loud. Avoid long strings and look-alike characters. Stick to a common top-level domain for a public site; use subdomains to separate products or regions only when it helps readers.
How to Make a URL For Files And Pages
You’ll often turn a file or title into a link slug. The steps below keep things tidy. When you ask how to make a url for a page, start with the scheme and base, then build a short, readable path.
Turn A Title Into A Slug
Lowercase the title. Replace spaces with hyphens. Strip punctuation other than hyphens. Collapse double hyphens. Keep 3–8 words if the title is long.
Make A File Name Web-safe
For static files, prefer letters, numbers, hyphens, and dots for the extension. Avoid spaces. If a file name already has spaces, encode them in the link as %20, or rename the file.
Map Folders To Paths
Keep a shallow folder layout. Mirror that shape in paths. A path like /guides/url-basics beats /content/2025/11/05/article-12345.
Add A Trailing Slash Or Not
Pick one style for a section and stick to it. Many servers treat a path directory like /docs/ differently from a file path like /docs. Serve one version and redirect the other to avoid duplication.
When To Use Query Strings
Use query strings for filtering, paging, and tracking that your app reads on the server or client. Keep names short, like page, sort, ref. Avoid stuffing personal data there. For marketing, use widely known names only when needed.
Fragments Done Right
Fragments don’t hit the server; they tell the browser where to land on the page or how to set state in a client app. Keep them short, use letters, digits, and hyphens, and avoid spaces.
International Text In URLs
Modern browsers accept non-ASCII characters, yet many tools expect ASCII. Use UTF-8 percent-encoding for paths and queries. For domains, use Punycode behind the scenes; people can still type the readable form.
HTTP, HTTPS, And Security
Use https almost everywhere. It protects the request from snooping and tampering and avoids mixed-content warnings when a page loads insecure resources. Use http only for local testing or content that truly cannot serve over TLS.
Common URL Schemes
- https: web pages and APIs
- http: legacy or local
- mailto: email addresses
- tel: phone numbers
- ftp: legacy file transfer where needed
- file: local files during testing, not for public links
- data: small inline content; use with care
- webcal: subscription links for calendars
How Browsers Resolve Relative Links
When you write href="guide.html" inside /docs/, the browser combines it with the base URL to form /docs/guide.html. You can also set a <base> tag in the head so all relative links resolve against that base. For a gentle primer on parts and behavior, see the MDN guide to URLs.
Canonicalization And Redirects
Pick a single canonical URL for each page so signals roll up to one address. Redirect old paths to new ones with 301 rules. Keep redirect hops to one when you can.
Human-Readable Vs Machine-Readable
Aim for both. People should know what a link points to before they click. Machines should parse it cleanly. Use consistent slugs, simple parameters, and stable anchors.
Testing Your URLs
Do a quick pass before launch:
- Paste the link into a new tab and press Enter.
- Try it in a second browser and on a phone.
- Check the path and query after redirects.
- Run a linter or a build task that catches malformed links.
Spot-Fixing Broken Links
If a link 404s, check the scheme and host first. Then look for stray spaces or double slashes. Confirm case on case-sensitive servers. Inspect redirects that may drop fragments or queries.
Table: Frequent URL Errors And Fixes
| Problem | What’s Wrong | Quick Fix |
|---|---|---|
| Space in path | Unencoded character | Replace with hyphen or %20 |
| Uppercase path | Mismatch on some hosts | Use lowercase paths |
| Bad query characters | Reserved symbols unencoded | Percent-encode reserved marks |
| Wrong scheme | Mixed content or failure | Use https where possible |
| Stale redirect | Chain or loop | Update rules to point direct |
| Unicode not encoded | Breaks in old tools | UTF-8 then percent-encode |
| Missing trailing slash | Directory vs file confusion | Serve one and redirect the other |
Make URLs For App Routing
Single-page apps still need shareable addresses. Surface state in the path where it maps to real content, and keep transient state in queries or fragments. Use the History API so the Back button works.
How To Document Your Rules
Write a tiny style guide for your team: schemes in use, slug rules, query names, and redirect habits. Add examples. Keep it near your repo so PRs can point to it.
Edge Cases You’ll Meet
Internationalized domains, IPv6 hosts in brackets, userinfo in legacy feeds, or ports on non-standard services. Handle these only when required; avoid exposing them in public links unless readers benefit.
SEO-Friendly, Reader-Friendly Slugs
Use words people use. Keep paths short. Avoid filler words that add length without meaning. Keep IDs only when your stack demands them.
Tracking Without Clutter
When you add UTM tags, keep the set small and stable. Don’t chain multiple tracking systems in one link. Strip tracking on internal links so your own analytics stay clean.
Privacy-Aware Links
Never put secrets, tokens, or personal data in a URL. Browsers and servers log addresses. If you must send sensitive data, move it to an authenticated request body or use short-lived POST forms.
Content Types And Downloads
When a link points to a file, set the correct MIME type on the server. If you want the browser to download, add the download attribute on an anchor for same-origin files.
Tooling You Can Use
Linters in CI that scan for bad links. Static site generators that slug titles the same way each time. Shortener tools on your domain. Browser devtools to watch redirects and mixed content.
Build URLs In Code
JavaScript: Use the URL constructor to build and validate links. It parses parts and handles encoding rules for you. If you ever wonder how to make a url from parts, this is the safest route for browser code.
JavaScript Snippet
const u = new URL("/guide", "https://example.com");
u.searchParams.set("q", "caf\u00e9");
console.log(u.href);
Server-Side Checks
On the server, reject schemes and hosts you don’t expect. Allowlist domains for redirects from user input. Log link errors with enough detail to fix them later.
Common Myths Cleared Up
- “Underscores are fine.” They work, but hyphens read better.
- “Uppercase is ok.” Some hosts treat
/Aboutand/aboutas different; stick to lowercase. - “Queries hurt ranking.” They don’t by themselves; the bigger issue is messy, changing parameters.
- “Long slugs rank better.” Clarity wins; long, vague strings don’t help readers.
A Short Workflow You Can Reuse
- Draft the path from the page title.
- Check the slug against your style guide.
- Add only needed parameters.
- Test with copy-paste in two browsers.
- Ship one canonical address and set the redirect.
Keep this flow and you’ll spend less time chasing broken links and more time shipping. Links should last.
