Sub topic 3
What a Slug Is and Why It Matters
This chapter assumes you can read basic HTML, including the a element and its href attribute. It also assumes you know a page is fetched with an HTTP request and that you know roughly what SEO is for. The previous chapter split a URL into scheme, host, path, query, and fragment. This chapter focuses on one piece of the path, the slug. It covers what the slug is, what it does and doesn't do for search, and which edge cases cause trouble.
What a slug is
A slug is the human-readable part of a URL that identifies one specific page. It is usually the last segment of the path, written in words instead of numbers.
https://example.com/blog/internal-linking-tips/
└──────────┬─────────┘
slugIn this URL, blog is a section and internal-linking-tips is the slug. The term comes from newspaper publishing, where a "slug" was a short label for a story in production. Content management systems (CMS) adopted the word for the short text version of a title.
The slug is not a formal part of the URL standard. RFC 3986 defines path segments but says nothing about slugs. "Slug" is a convention that CMSs, frameworks, and SEO practice share. That affects how you handle edge cases, because the rules come from your site and not from the specification.
Slug versus path versus full URL
People use these terms loosely. Here is how this tutorial uses them.
| Term | Example | Meaning |
|---|---|---|
| Full URL | `https://example.com/blog/internal-linking-tips/` | Scheme, host, path |
| Path | `/blog/internal-linking-tips/` | Everything after the host, before any query |
| Folder or section | `/blog/` | A path segment that groups pages |
| Slug | `internal-linking-tips` | The final segment, which names this page |
Some systems let you edit the whole path, others only the last segment. WordPress, for example, lets you edit the slug while the /blog/ prefix comes from a permalink setting.
Reading a slug in code
You will often need the slug programmatically, for example when auditing a list of URLs or mapping old addresses to new ones. This script uses only the standard library.
from urllib.parse import urlsplit
def get_slug(url):
path = urlsplit(url).path
segments = [s for s in path.split("/") if s]
return segments[-1] if segments else ""
urls = [
"https://example.com/blog/internal-linking-tips/",
"https://example.com/blog/internal-linking-tips",
"https://example.com/",
"https://example.com/products?id=4821",
"https://example.com/blog/post.html?utm_source=news#top",
]
for url in urls:
print(repr(get_slug(url)))The output is:
'internal-linking-tips'
'internal-linking-tips'
''
'products'
'post.html'Three things are worth noticing:
- The trailing slash makes no difference to the slug. It can still matter to the server, which Chapter 7 covers under duplicate URLs.
- The home page has no slug. Its path is
/. /products?id=4821has a slug (products) that says nothing about which product the page shows. The real identifier is in the query string, so the URL doesn't describe the page.
What a slug does
A slug does four jobs, and its weight differs between them.
1. It describes the page to people
Readers see URLs in many places: the address bar, the status bar when hovering over a link, a message pasted into chat, a printed handout, and the link text when someone pastes a bare URL into a post. A slug like /guides/url-slugs/ tells them what to expect before they click. A slug like /p/83921 tells them nothing.
This is the most dependable benefit. A descriptive URL gets more trust and is easier to recognize, copy, and remember.
2. It gives search engines a small content signal
Search engines read the words in a URL along with the title, headings, body text, and link context. Google's guidance says that URLs with readable words are helpful, and it treats the words in a URL as a very lightweight ranking signal. Treat the slug as a tiebreaker, not a ranking lever. A page with a perfect slug and weak content will not outrank a stronger page with an ugly one.
Search results also often show the URL, or a breadcrumb built from it, under the title. A clear slug can make a result look more relevant at a glance.
3. It acts as the page's identifier
Search engines index pages by URL. Other sites link to that URL, and your own pages link to it. Bookmarks and shared messages store it. Once a page has been public for a while, its URL is its identity. If the slug changes without a redirect, the old URL returns a 404 error and the page loses the links and history attached to it. Chapter 6 covers how to change a slug safely. For now, the main point is that a slug is cheap to choose and expensive to change.
4. It helps you manage a site
Descriptive slugs make it easier to find a page in an analytics report, a server log, a sitemap, or a crawl export. When a report lists /blog/internal-linking-tips/ instead of /blog/?p=1847, you can tell which page it means without opening it.
What a slug does not do
Some claims about slugs are common but wrong.
- It does not replace good content. Stuffing keywords into the slug does not compensate for a thin page.
- It does not need to match the title word for word. The title is for the page's heading and search result. The slug should be a short label for it. A title such as "10 Easy Ways to Improve Your Internal Linking Without a Site Redesign" can have the slug
improve-internal-linking. - It is not a place to repeat every keyword. A slug such as
seo-seo-tips-best-seo-tipsreads as spam to people, and it earns nothing from search engines. - It does not have to reflect the full site hierarchy. Deep folder paths make URLs long, and moving a page between folders changes its URL.
A comparison of slug styles
The examples below target the same hypothetical page about running shoes.
| URL | Verdict |
|---|---|
| `/shoes/running-shoes-guide/` | Descriptive and short. A good default. |
| `/p?id=83921` | Opaque. It says nothing about the page, and query parameters can create duplicates. |
| `/2026/11/27/our-running-shoes-guide-updated-final/` | The date and the word "updated" will go stale, and the URL forces a change at the next revision. |
| `/Running_Shoes_Guide` | Mixed case and underscores. Paths are case-sensitive on many servers, so this invites duplicates. |
| `/best-running-shoes-cheap-running-shoes-buy-running-shoes/` | Repetition. It looks like keyword stuffing. |
The next chapter turns these observations into concrete writing rules.
Edge cases to know about
Titles change, slugs shouldn't
Many CMSs generate the slug from the title when you create a draft. Some regenerate it when you edit the title, unless you lock it. If you retitle a published post and the slug follows, the old URL starts returning 404. Check this setting in your CMS before bulk-editing titles.
Slugs must be unique within their scope
Two pages in the same folder can't share a slug. CMSs usually resolve a collision by appending a number, such as running-shoes-guide-2. That number tells the reader nothing, so it is better to choose a distinct, descriptive slug. Search for an existing page with a similar name before you publish.
The slug isn't always the last segment
A page can be served as /guides/url-slugs/index.html or /guides/url-slugs.html. In those cases, the visible "slug" includes a file extension, as the post.html result in the code example showed. Extensions can leak implementation details and make a migration harder, for example when you move from static HTML to a CMS. Modern setups usually serve extensionless URLs.
Case sensitivity differs by layer
The host name is case-insensitive. The path, and therefore the slug, is case-sensitive on most web servers. /Guides/URL-Slugs/ and /guides/url-slugs/ can be treated as different URLs. Search engines may then index both and treat them as duplicates. Keeping slugs in lowercase avoids the problem.
Non-English titles
A title in another script or with accents needs a decision: transliterate to ASCII, or keep the original characters. This chapter does not settle that. Chapter 5 covers encoding, because non-ASCII characters in a URL are percent-encoded and can look unreadable when copied.
A quick audit habit
You can check any slug with three questions:
- Could someone guess what the page is about from the slug alone?
- Would the slug still be accurate in three years?
- Is this the only URL that serves this page?
A "no" to any of them marks a slug to fix before you publish. Once the page is live, fix it with a redirect, not by editing the URL in place.
Exercise
A CMS publishes a post at /blog/10-tips-for-2026/. In January 2027 the editor retitles it "12 Tips for 2027" and the CMS regenerates the slug to /blog/12-tips-for-2027/ with no redirect. Name two problems this causes and one slug choice that would have avoided them.
Show answer
First, the old URL now returns 404, so every external link, bookmark, and indexed result pointing to it breaks, and the page loses the signals attached to that URL. Second, internal links that still point to the old slug become broken links. A year and a number in the slug make it go stale each time the content is updated. A durable slug such as /blog/seo-tips/ would have stayed accurate, and the title could have changed freely.
Exercise
Using the get_slug function from this chapter, what does it return for https://example.com/shop/Red-Shoes/?color=blue, and why might that URL cause a duplicate-content issue?
Show answer
It returns 'Red-Shoes'. The slug has capital letters, and paths are case-sensitive on many servers. /shop/Red-Shoes/ and /shop/red-shoes/ may both resolve and be treated as separate URLs. The ?color=blue query parameter can create yet another variant of the same content.