Explainers · Explainer
What Is a Slug in WordPress? A Plain Explanation

Short answer
A slug is the short, readable part of a URL that names one post, page, category, or tag. WordPress builds it from the title when you first save the post, lowercasing the text and swapping spaces for hyphens.
Key takeaways
- A slug is the last part of a URL, such as how-to-bake-bread in example.com/how-to-bake-bread.
- WordPress builds the slug from the title with sanitize_title(), which has existed since version 1.0.0.
- A good slug is three to five plain words, lowercase, with hyphens between words.
- If two posts share a slug, WordPress adds -2 to the second one.
- Changing a slug on a live post breaks the old address unless you add a 301 redirect.
What is a slug in WordPress?
A slug is the short, readable part of a URL that names one post, page, category, or tag.
In the address example.com/how-to-bake-bread, the slug is how-to-bake-bread. It is the last part of the address, after the domain name, and it tells readers what the page is about before they open it.
WordPress stores the slug as the post_name field of the post, and the developer reference for wp_unique_post_slug() calls it the desired slug. Slugs exist for posts, pages, categories, tags, and authors, and each one must be unique within its own type.
How does WordPress create a slug?
WordPress builds the slug from the title when you first save a post, using the sanitize_title() function.
The function lowercases the text, swaps spaces for hyphens, and strips out punctuation and other characters that do not belong in an address. The developer reference says it converts accented characters to plain ASCII and limits the result to letters, numbers, underscores, and dashes.
WordPress.org gives a clear example in its permalink guide: the title “This Is A Great Post!” becomes this-is-a-great-post in the address. The %postname% tag in a permalink structure inserts this slug for each post.
sanitize_title() has been part of WordPress since version 1.0.0. In its save context it runs remove_accents() first, so café becomes cafe. If the title is empty and a fallback title is set, the fallback is used instead.
Where does a slug appear in a URL?
The slug sits at the end of the permalink, after the domain and any date or category parts.
With the “Post name” structure, the address is just the domain plus the slug: example.com/how-to-bake-bread. With the “Day and name” structure, the date comes first: example.com/2026/11/21/how-to-bake-bread.
Category and tag slugs work the same way. A category page lives at example.com/category/recipes, where recipes is the category slug. The permalink guide notes that the default bases are category and tag, and that nested sub-categories show as nested folders in the address.
The slug is not the whole permalink. The permalink is the full address, while the slug is only the last part. Our guide to the best permalink structure for SEO explains how the parts fit together.
How do you change a slug?
Open the post in the editor, click the URL field in the post settings sidebar, and type the new slug.
Save the post as a draft first if it is new, since WordPress creates the first slug when you save. Then open the URL field, replace the text with your new slug, press Enter, and click “Update” to save it.
You can also change a slug from the posts list with Quick Edit. Go to “Posts → All Posts”, hover over the post, click “Quick Edit”, change the slug field, and click “Update”. The same steps work for pages under “Pages”.
For categories and tags, go to “Posts → Categories” or “Posts → Tags” and edit the slug field on the category or tag screen. Our guide to categories vs tags in WordPress explains when to use each one.
Learn WordPress shows the same editor steps in its lesson on managing permalink settings.
What makes a good slug?
A good slug is short, uses plain words, and says what the page is about.
Google's URL guidance asks for readable words instead of long ID numbers, and for hyphens between words instead of underscores. Google Search Central notes that hyphens mark word boundaries clearly, while underscores are often read as joining words together.
Keep the slug to three to five words that match the page topic. Drop filler words such as “and”, “the”, and “how to” unless they are needed to make sense of it. Use lowercase only, since Google treats /APPLE and /apple as two different addresses.
| Post title | Slug | Why it works |
|---|---|---|
| How to Bake Sourdough Bread at Home | bake-sourdough-bread | Short, plain words, no filler |
| 10 Best Budget Laptops for Students in 2026 | best-budget-laptops-students | Drops the number and the year |
| What Is a Permalink? A Plain Explanation | what-is-a-permalink | Matches the question readers ask |
| Our Company History Since 1998 | company-history | Short and free of a stale date |
Match the slug to the page topic, not to the exact title. A title can be long and catchy, while the slug stays short and plain.
What happens if two posts have the same slug?
WordPress adds a number to the second slug, such as -2, so the two addresses stay different.
The wp_unique_post_slug() function computes a unique slug when a post is saved, and the developer reference says it adds a -1, -2, and similar suffix when the slug is already taken. The check runs when the post is published, not while it is still a draft or pending review.
This matters most for pages, where two pages with the same title are common. “Contact” and “Contact” become contact and contact-2, and only the second one gets the number.
If you see -2 at the end of a slug, check whether an older post or a trashed post already uses the plain version. Deleting the older item or changing its slug frees the plain version for the new post.
What happens when you change a slug on a live post?
The old address stops working, and anyone who follows it lands on a 404 error page.
WordPress does not redirect the old address on its own. WordPress.com states the same warning in its permalink guide: when you change the permalink setting, posts may not automatically redirect from the old links, so use a redirection plugin.
Add a 301 redirect from the old slug to the new one before you change it, or right after. A 301 tells search engines and browsers that the page has moved for good, and it passes the old page's standing to the new address.
Check the change after you save it. Open the old address in a private window and confirm it lands on the new page, then open the new address and confirm the page loads. Our guide to how to set up 301 redirects in WordPress shows the steps.
What mistakes should you avoid with slugs?
The biggest mistake is changing a slug on a published post without a redirect.
A second mistake is stuffing the slug with keywords. A slug such as best-cheap-affordable-budget-laptops-deals-2026-buy-now reads as spam and is hard to share. Three to five plain words beat a long string of keywords.
A third mistake is using dates in slugs for content that stays useful. A guide with 2021 in its slug looks dated even when the advice is still current, so leave the year out unless the year is the point of the page.
A fourth mistake is using underscores or joined words. Google recommends hyphens between words, and underscores make the words run together for readers and search engines alike.
A fifth mistake is changing slugs often. Every change breaks links and costs search standing, so pick a slug you can live with and leave it alone. Our guide to how to change permalinks without breaking SEO covers the full checklist.
Our guide to how to set up permalinks in WordPress shows how the slug fits into the whole address.
Frequently asked questions
What is the difference between a slug and a permalink?
A slug is only the last part of the address, while a permalink is the full address. In example.com/my-post, my-post is the slug and the whole string is the permalink. You change the slug in the post editor, and you change the permalink pattern under Settings and then Permalinks.
Can I change a slug after publishing?
Yes, but set up a 301 redirect from the old address to the new one first, or right after. Without a redirect, every link and bookmark pointing to the old address lands on a 404 error page, and the page loses its search standing.
Why does my slug end with -2?
WordPress adds a number to the end, such as -2, so the two addresses stay different. This happens when a post is published, not while it is a draft. If you see -2 on a slug, check whether an older or trashed post already uses the plain version.
Does the slug change when I change the title?
No. WordPress builds the slug from the title when you first save the post, and later title changes leave the slug alone. If you want the slug to match a new title, edit the slug by hand in the post editor and add a redirect from the old address.
How long should a slug be?
Keep it to three to five plain words that say what the page is about. Drop filler words such as the and and, use hyphens between words, and keep everything lowercase. Leave out dates unless the year is the point of the page.
Can I change the slug of a page or category too?
The same steps work for pages, categories, and tags. Edit a page slug in the page editor or from the Pages list, and edit a category or tag slug from Posts and then Categories or Tags. Each slug must be unique within its own type.
Sources
- sanitize_title() WordPress Developer Resources
- wp_unique_post_slug() WordPress Developer Resources
- Customize permalinks WordPress.org
- URL Structure Best Practices for Google Search Google Search Central
- Change the permalink structure WordPress.com Support
- Managing Settings: Permalinks Learn WordPress
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


