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.
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.
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!
- Event July 11, 2022 Team Yoast is Speaking GoDaddy Pro EMEA (Online), click through to see if we'll be there, who will be there and more! See where you can find us next »
- SEO webinar 19 July 2022 Our SEO expert Jono Alderson will keep you up-to-date about everything that happens in the world of SEO and WordPress. All Yoast SEO webinars »