SEOApril 2026·9 min read

URL Encoding, Slugs & SEO-Friendly URLs

Every web page lives at a URL, and how that URL is structured affects both how browsers handle it and how search engines rank it. This guide covers the mechanics of URL encoding, the art of slug generation, and the SEO principles behind clean, readable permalinks.

🔗
Try the URL Encoder/Decoder
Encode and decode URLs instantly — free, no signup
DG
Derek Giordano
Designer & Developer
In this guide
01Anatomy of a URL02Percent-Encoding Explained03Encoding & Decoding in JavaScript04Query Strings & Parameters05What Is a URL Slug?06Slug Best Practices07SEO-Friendly URL Structure08Trailing Slashes09Redirects & Canonicalization
⚡ Key Takeaways
  • Understand URL encoding, percent-encoding, slug generation, and SEO-friendly URL structure.
  • Covers anatomy of a url.
  • Covers percent-encoding explained.
  • Covers encoding & decoding in javascript.
  • Covers query strings & parameters.

Anatomy of a URL

A URL (Uniform Resource Locator) has several distinct parts, each serving a specific purpose:

https://www.example.com:443/blog/my-post/?ref=twitter#comments └─┬──┘ └──────┬──────┘└┬┘└─────┬─────┘└────┬────┘└───┬───┘ scheme host/domain port path query fragment

The scheme (https) tells the browser which protocol to use. The host identifies the server. The path points to a specific resource. The query string passes key-value parameters. The fragment links to a section within the page.

URLs can only contain a limited set of ASCII characters. When you need to include spaces, special characters, or non-ASCII text (like accented letters or emoji), they must be percent-encoded.

Percent-Encoding Explained

Percent-encoding (also called URL encoding) replaces unsafe characters with a % followed by two hexadecimal digits representing the character's byte value. For example, a space becomes %20, an ampersand becomes %26, and a forward slash becomes %2F.

💡 Tip
Always include -webkit-backdrop-filter alongside backdrop-filter for Safari support. Without the prefix, the effect is invisible to roughly 25% of mobile users.
Space → %20 (or + in query strings) & → %26 = → %3D ? → %3F # → %23 / → %2F @ → %40 café → caf%C3%A9 (UTF-8 bytes for 'é')

Characters that are safe to use unencoded in URLs include letters (A–Z, a–z), digits (0–9), and a handful of symbols: - _ . ~. Everything else should technically be encoded, though browsers handle most of this automatically.

The distinction between encoding an entire URL versus encoding a component matters. A full URL contains reserved characters like ://, /, and ? that have structural meaning and should not be encoded. But within a query parameter value, those same characters need encoding so they don't break the URL structure.

Encoding & Decoding in JavaScript

JavaScript provides two pairs of encoding functions, each suited to different use cases:

⚠ Warning
On iOS Safari, backdrop-filter inside a position: fixed element can cause severe scroll performance issues. Test thoroughly on real iOS devices.
// encodeURIComponent — for query params and path segments encodeURIComponent("hello world & more") // → "hello%20world%20%26%20more" // encodeURI — for full URLs (preserves ://?#& etc.) encodeURI("https://example.com/path?q=hello world") // → "https://example.com/path?q=hello%20world" // Decoding decodeURIComponent("hello%20world") // → "hello world" decodeURI("https://example.com/caf%C3%A9") // → "https://example.com/café"

Use encodeURIComponent() when encoding individual values (form data, query parameters, path segments). Use encodeURI() when encoding a complete URL where you want to preserve the structural characters. The URL Encoder/Decoder tool handles both modes.

The URLSearchParams API

For building query strings, the modern URLSearchParams API handles encoding automatically:

const params = new URLSearchParams({ q: "hello world", page: "2", filter: "price<100" }); params.toString() // → "q=hello+world&page=2&filter=price%3C100"

Query Strings & Parameters

Query strings begin with ? and contain key-value pairs separated by &. They're used for search queries, filters, tracking parameters, pagination, and API requests.

/search?q=design+tools&category=css&page=2 /products?sort=price&order=asc&min=10&max=100

In query strings specifically, spaces can be encoded as + instead of %20. Both are valid, but + is more compact and commonly used in form submissions. Outside of query strings, always use %20 for spaces.

Keep query strings as short as practical. Very long URLs can cause issues with some servers, proxies, and social media platforms that truncate URLs. If you need to pass complex data, consider using POST requests instead of embedding everything in the URL.

What Is a URL Slug?

A slug is the human-readable part of a URL that identifies a specific page. In /blog/css-gradient-guide/, the slug is css-gradient-guide. Good slugs are short, descriptive, and use only lowercase letters, numbers, and hyphens.

The term comes from newspaper publishing, where a "slug" was a short label used to identify a story during editing. In web development, slugs serve the same purpose — they're compact identifiers that are also readable by humans.

Original title: "The Complete Guide to CSS Gradients (2026)" Generated slug: css-gradient-guide Original title: "10 Tips for Better Web Performance!" Generated slug: 10-tips-better-web-performance

Slug Best Practices

Use hyphens as word separators, not underscores. Google treats hyphens as word separators but historically treated underscores as joiners, so css-gradient is two words while css_gradient might be treated as one. Hyphens are also the web convention and what users expect to see in URLs.

Keep slugs short and focused on the primary keyword. Remove stop words like "the", "a", "and", "of", "to" when they don't add meaning. complete-guide-css-gradients is better than the-complete-guide-to-css-gradients-in-2026.

Use only lowercase letters. URLs are technically case-sensitive on most servers, and mixed case creates confusion and potential duplicate content issues. The Slug Generator handles all of this automatically — lowercase conversion, special character removal, and hyphen separation.

Avoid dates in slugs unless the content is genuinely time-dependent (like a news article). /blog/css-gradient-guide/ is evergreen, while /blog/2026/04/css-gradient-guide/ will look stale next year even if you update the content.

SEO-Friendly URL Structure

Search engines use URL structure as a ranking signal, though it's a relatively minor one compared to content quality and backlinks. Still, clean URLs improve click-through rates because users can read them in search results and understand what the page contains before clicking.

Flat URL structures tend to perform better than deep nesting. /tools/gradient-builder/ is preferable to /category/css/tools/generators/gradient-builder/. Each level of nesting dilutes the perceived importance of the page and makes the URL harder to read.

Include your target keyword in the slug, but don't stuff it. One clear mention is enough. /blog/css-gradient-guide/ is good; /blog/css-gradient-guide-best-css-gradients-gradient-tutorial/ is keyword stuffing and can hurt rankings.

Keep the full URL path under approximately 60-75 characters when possible. While there's no hard technical limit, shorter URLs are easier to share, copy, and display in search results.

Trailing Slashes

Whether your URLs end with a trailing slash (/blog/guide/) or without (/blog/guide) is a matter of convention, but consistency is critical. Search engines treat these as different URLs, so serving the same content at both creates duplicate content issues.

Pick one convention and enforce it with redirects. If someone visits the non-canonical version, redirect them to the canonical one with a 301 (permanent) redirect. On Netlify, you can handle this in the _redirects file or with the Pretty URLs setting in your site configuration.

Redirects & Canonicalization

When you change a URL — whether you're restructuring your site, renaming a slug, or migrating to a new domain — always set up a 301 redirect from the old URL to the new one. This tells search engines to transfer the old page's ranking signals to the new URL and prevents users from hitting broken links.

# Netlify _redirects file /old-page-name/ /new-page-name/ 301 /blog/2025/post/ /blog/post/ 301

The canonical meta tag in your HTML tells search engines which version of a page is the "official" one. This is essential when the same content might be accessible at multiple URLs (with/without www, with/without trailing slash, with different query parameters):

Every page on your site should have a canonical tag pointing to its preferred URL. This single tag prevents most duplicate content issues and ensures search engines consolidate ranking signals correctly.

Encode URLs & generate slugs

Use the URL Encoder to encode and decode URLs, and the Slug Generator to create clean, SEO-friendly slugs from any title.

⚡ URL Encoder🔗 Slug Generator
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.
📚 References & Further Reading