Sub topic 3
What a slug is and why it matters
This chapter assumes you can read a URL and know that a search engine finds pages by following links. It also assumes you have read the previous chapter on the parts of a URL.
What a slug is
A slug is the part of a URL that identifies one page in human-readable words. It is usually the last segment of the path.
https://example.com/blog/url-slugs-guide/
└── slug: url-slugs-guideThe segments before it (/blog/) describe where the page lives. The slug describes what the page is about. Content management systems often generate the slug from the page title, which is where the word comes from. Many systems let you edit it by hand.
The following code splits a URL into path segments and picks out the slug.
from urllib.parse import urlparse
url = "https://example.com/blog/url-slugs-guide/"
path = urlparse(url).path
segments = [part for part in path.split("/") if part]
print(segments) # ['blog', 'url-slugs-guide']
print(segments[-1]) # url-slugs-guideWhy the slug matters
A slug does four jobs, and the first is the least important.
- A small relevance hint. Search engines read the words in a URL along with the title, headings, and body text. Google has described this as a lightweight signal. A good slug supports the page's topic but will not rescue a weak page.
- A preview for readers. Search results, browser address bars, and messages show the URL or part of it. A slug like
url-slugs-guidetells a reader what to expect before they click. A slug likep?id=48213tells them nothing. - Default link text. When someone pastes a bare URL into a forum, chat, or document, the URL itself becomes the visible text. Readable words make that text useful.
- A stable identifier. Other sites, bookmarks, and your own internal links all point at the full URL. The slug is part of that address, so it is part of the page's identity.
The fourth job is the one that causes trouble. Search engines treat a URL as the page's address. If you change the slug, you create a different address. The old address still exists in links, bookmarks, and the search index until you deal with it.
Slug versus the rest of the URL
| Part | Example | Who usually controls it |
|---|---|---|
| Domain | `example.com` | Site owner, rarely changed |
| Folder path | `/blog/` | Site structure |
| Slug | `url-slugs-guide` | Author or editor, per page |
| Query string | `?utm_source=news` | Tracking tools or filters |
Only the slug is chosen per page by the person writing the content. That is why it deserves a deliberate decision.
A worked comparison
Suppose you publish an article about choosing running shoes. Compare three possible slugs for the same page:
/blog/post-48213: stable, but it says nothing about the content./blog/how-to-choose-running-shoes-for-flat-feet-in-2026-complete-beginner-guide: descriptive, but long and tied to a year you will have to update./blog/choosing-running-shoes: short, readable, and unlikely to need changing.
The third is a reasonable default. The next chapter turns this judgment into concrete rules.
Common mistakes at this stage
- Treating the slug as a ranking lever and stuffing it with keywords. It is a small hint, and keyword lists read as spam to people.
- Letting the system auto-generate a slug from a long working title, then forgetting to check it before publishing.
- Assuming a slug identifies a page by itself. Two pages in different folders can share a slug and still be different URLs.
- Putting dates or version numbers in the slug without a plan for updating the content.
Exercise
A colleague changes the slug of a published article from /blog/seo-tips to /blog/internal-linking-tips and does nothing else. Name two things that can go wrong, and explain why they happen.
Show answer
First, every existing link to /blog/seo-tips, from other sites, bookmarks, and your own pages, now points to an address that no longer exists, so visitors get a 404 error. Second, search engines treat the new URL as a different page from the old one, so the old page's place in the index and the value of its inbound links do not transfer cleanly. Both problems happen because the slug is part of the page's address, and a redirect is needed to connect the old address to the new one.