What is a slug and how to optimize it?
When we talk about SEO for WordPress, we often talk about creating the right slug for a page. Of course, we’re not talking about the slimy creature that eats your plants. So, what is this ‘slug’, then? And why should you optimize it? In this post, we’ll explain all you need to know about it.
Having an orange or red bullet for the ‘keyphrase in slug‘ check in Yoast SEO? Here’s what that check does and how to turn that bullet green.
Table of contents
What is a slug?
A slug is the part of a URL that identifies a particular page on a website in an easy-to-read form.
In other words, it’s the part of the URL that explains the page’s content. For this article, for example, the URL is https://yoast.com/slug, and the slug simply is ‘slug’.
Here’s a video that explains more:
How to edit a URL slug
In WordPress, the slug is the part of your URL that you can edit when writing or editing a post. Editing it in WordPress looks like this:
Note that this only works with the right permalink settings. You can edit the permalink settings in WordPress through Settings > Permalinks. We recommend choosing an option in which the URL contains relevant words, as this provides users and search engines with more information about the page than an ID or parameter would.
Note: don’t just change your permalink settings once your site is already online. This could cause all kinds of trouble.
There are two ways to edit a slug in Shopify: you can do it using Shopify’s ‘Search engine listing preview’ function, or you can use the Google Preview tool in Yoast SEO for Shopify instead.
To edit a slug using the in-built Shopify function, you’ll first need to click on ‘Edit website SEO’ to open the Search engine listing preview options. From there, you can easily adjust your slug as necessary. Note that Shopify calls the slug the ‘handle’ instead, but it’s exactly the same thing.
Alternatively, if you’re editing your Shopify page with Yoast SEO, all you need to do is open the Google preview in the Yoast SEO sidebar and you’ll see a field to enter a new slug:
Why are URL slugs important for SEO?
Writing a good slug for your page or post can positively affect your SEO. It allows you to do the following things:
1. Include your keyword in the URL slug
The main SEO benefit of a slug is that you can change the words to make sure that it has the words that you really want to rank for. It’s one of the indicators Google uses to determine what a page is about.
2. Create user-friendly URL slugs
The URL is also one of the things that people sometimes see in search results. Picture a results page: you’ll see many different URLs about a certain topic, right? So you need to make sure your slug is in line with what people expect to see. For example, our main article on WordPress SEO has the URL yoast.com/wordpress-seo, which is very on point. People are a lot more likely to click on that, than on yoast.com/?p=607, even though that’s the URL that WordPress creates by default.
Find out more about creating SEO-friendly URLs »
What does the keyphrase in slug assessment in Yoast SEO do?
One of the SEO assessments in the Yoast SEO plugin checks whether the slug contains your focus keyphrase. Your article or page should live on an easy to remember, focused and SEO-friendly URL. To improve the URL, Yoast SEO checks how you’ve fitted in your main focus keyphrase and makes suggestions to improve it.
How to optimize your slug in WordPress
What are the things you need to think of when constructing the right slug for your post or page? Let’s go over five steps of optimizing it in WordPress:
- Include your focus keyphrase
This is probably a no-brainer, but your focus keyphrase should always be in the slug. It has to make clear what your page is about immediately. The SEO analysis in the Yoast plugin will show this message if your keyphrase isn’t in the slug.
- Think about function words
The slug that’s generated by default may include function words like “a”, “the” and “and” and similar words. In some cases, you might need those in it to clarify what your page is about, but usually, you can leave them out. You can read more about this in our WordPress SEO article.
- Add focus
Don’t just filter out unnecessary function words, but really all the words that you don’t need. In the case of this post, WordPress automatically created the slug “what-s-a-slug-and-how-to-optimize-it” (based upon the permalink settings in WordPress). That’s quite long, so we manually reduced it to “slug”. Make sure it still makes sense, though.
There is one thing to keep in mind here. You can use a slug only once, so you should use it for the right page. If we want to write another, different post about slugs in the future, then we can’t (re)use this slug.
- Keep it short and descriptive permanent
The URL of your page is sometimes shown in Google search results, and it may influence whether your audience decides to click your snippet. But there’s not a lot of room to play with. That makes it important to think about the specific words you include.
Be careful adding dates and such to your URL, as these will instantly give away when content was originally published.
- Use lowercase letters only
Try to use lowercase letters only in your slug. That’s because, in some cases, you can create duplicate content by mixing uppercase and lowercase letters.
- Remember that URL slugs should be permanent
Changing URLs can be bad for SEO, and bad for users – even if you use a redirect manager to make sure that people get to the right place. So when you’re choosing your slug, make sure it’s still going to make sense years from now.
WordPress for beginners series
Coming up next!
WordCamp EuropeJune 08 - 10, 2023 Team Yoast is Attending, Organizing, Speaking, Sponsoring WordCamp Europe. Click through to see who we'll be there, what we'll do there and more! See where you can find us next »
Yoast SEO news webinar - June 20, 202320 June 2023 Our head of SEO, Jono Alderson, will keep you up-to-date about everything that happens in the world of SEO and WordPress. All Yoast SEO webinars »
19 Responses to What is a slug and how to optimize it?
how many keywords I can use per post in the free plugin
You can only use 1 keyword or keyphrase.
For more information: https://yoast.com/wordpress/plugins/seo/
i have a question, i started a seo for a website 2 months ago, i run different free auditing tool and uber suggest suggest me to include key words in the url, i changed it and added keywords for all url, but suddenly all my ranking gone in serp and i landed in the last place in 7th page. and webmaster shows there are some errors in url crawlability? does ranking is related to url slugs? how can i retrieve my old rankings?
I’m sorry to hear that! Sounds like you changed the slug of pages that were already published? If you don’t redirect the old URL of live content to the new URL with the improved slug, you’ll get errors that can definitely harm your rankings. Check out this post for more information: https://yoast.com/create-301-redirect-wordpress/ .
BTW, Yoast SEO Premium makes redirects super easy and gives you the option to instantly implement a redirect when you’re changing the slug of published content, so you may want to check that out too… ;-) Good luck!
How many keywords can I use with yoast premium per post ?
With Yoast SEO premium you can use 5 keywords per post!
Thanks for asking.
Hi! I created a new page called podcast but I didn’t realized I had a picture named podcast so wordpress name the slug as podcast-2 (i have set permalinks as postname) I changed the pic name but I couldn’t change the slug. What can i do?
I still confuse between keyword and slug. Somehow I try to put these facts but rarely it show the result and it takes too much time.
Hi! Sorry to hear that! Maybe this’ll help: your keyword is the word or phrase you want to rank for. You optimize your post so it contains your keyword. It also helps if your keyword is used in the slug.
You’re absolutely right, SEO takes a lot of time and sometimes your efforts won’t pay off immediately, but hang in there, you’ll get there!
Thanks for sharing the valuable information.. I would like to know if it’s good to have deep category nesting ? or is it bad for SEO?
You’re welcome, James! Do you mean including the category in the URL? That’s certainly an option, yes, if you’re sure your URLs won’t become too long and unclear. Maybe you’ll find this post interesting: https://yoast.com/seo-friendly-urls/
If that’s not your question, please elaborate a bit more :)
What is the word limit of slug?
Hi Vishnu! While people sometimes advise to keep URL length (so not just the slug but the entire URL) under 100 characters, or even 70 characters, I’d say it’s most important to make sure your slug (and the rest of the URL) is concise, clear and descriptive. So try to focus on that!
Thanks for sharing such a readable article about the slug and its optimization, but I am just confused about when we changed those slugs from our site then will those links related to previous slug remains or get broken?
Hi Valencio! You’re very welcome :) To answer your question: If you change the slug of a page after publishing, you’ll need a redirect. Otherwise, existing links pointing to the old slug will be broken, as they’re referring to a slug that’s no longer used.
is there any ideal length for slug..?
Hi! Good question! There’s no ideal length, it depends on the content of your page and its place on your site. Ideally, though, the slug shouldn’t be too long: keep it short and focused, but make sure it’s instantly clear what your page is about. Hope that helps, good luck!
Still confused about the difference between slug and url. Is there any difference or both are same only?
The slug is part of the URL. So the full URL of this post is https://yoast.com/slug, and the slug of this URL is only the word ‘slug’. It’s the part of the URL that explains what page it is. Does this make it clearer? A URL is longer, and the slug is part of it!