What is a slug and how to optimize it?
When discussing 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 everything you need to know.
Do you have an orange or red traffic light for the ‘keyphrase in slug‘ check in Yoast SEO? Here’s what that check does and how to turn that light 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’.
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 either use 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 built-in 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: 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 scroll down to the search appearance section 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
Why? Because the slug is one of the indicators Google uses to determine what a page is about. So change your slug, and make sure that it includes words you really want to rank for.
2. Create user-friendly URL slugs
Picture a results page: you’ll see many URLs about a particular topic. 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 much more likely to click on that than on yoast.com/?p=607, even though that’s the URL WordPress creates by default.
Find out more about creating SEO-friendly URLs »
What does the keyphrase in slug assessment in Yoast SEO do?
Your article or page should have an easy-to-remember, focused and SEO-friendly URL. That’s why, to improve your URL, the Yoast SEO plugin checks how you’ve fitted in your main focus keyphrase and makes suggestions to improve it.
How to optimize your slug in WordPress
What do you need to consider when crafting the right slug for your post or page? Let’s go over the six 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. This will immediately make it clear to your audience what your page is about.
If your keyphrase isn’t in the slug, the SEO analysis in the Yoast plugin will show you this message: - Think about function words
The slug that’s generated by default may include function words like “a”, “the” and “and”. Sometimes, you might need those to clarify what your page is about. Usually, however, you can leave them out.
You can read more about this in our WordPress SEO article. - Add focus
You shouldn’t just filter out any unnecessary function words, but every word you don’t need. In the case of this post, WordPress automatically created the slug “what-is-a-slug-and-how-to-optimize-it” (based on the permalink settings in WordPress). That’s quite long, so we manually reduced it to “slug”. However, you should make sure your slug still makes sense!
And remember: You can use a slug only once, so use it for the right page. For example, if we want to write another (but different) post about slugs in the future, we can’t (re)use this slug. - Keep it short and descriptive
As we’ve said before, the URL of your page is sometimes shown in Google search results and may, therefore, influence whether your audience decides to click your snippet. So, you don’t have a lot of room to play with. So, think carefully about the specific words you want to include.
In addition, be careful when adding dates and such to your URL. These instantly tell your audience when your content was originally published. - Use lowercase letters only
Try to use only lowercase letters in your slug. If you don’t, you might accidentally 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 ensure that people get to the right place. So when choosing your slug, make sure it will make sense years from now.
WordPress for beginners series
Coming up next!
-
Event
Wordcamp Asia 2025
February 20 - 22, 2025 Team Yoast is at Attending, Sponsoring, Yoast Booth Wordcamp Asia 2025! Click through to see who will be there, what we will do, and more! See where you can find us next » -
SEO webinar
Webinar: How to start with SEO (January 16, 2025)
16 January 2025 Learn how to start your SEO journey the right way with our free webinar. Get practical tips and answers to all your questions in the live Q&A! All Yoast SEO webinars »