What is a slug and how to optimize it?

In SEO, 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.

What is a slug?

A slug is the part of a URL which 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 how Joost explained slugs in an Ask Yoast video:

WordPress slugs

In WordPress, the slug is the part of your URL that you can edit when writing a new post. Note that this only works with the right permalink settings. Editing your slug in WordPress looks like this:

editing your slug in WordPress

Things like the date or category name that are sometimes included in URLs, aren’t part of the slug. And if you have added more variables to your URL, the slug is still just that editable part of the URL to the page, like this:


There’s an additional value at the end of that URL. In this case, that extra variable is used so slugs can be the same without the URL being the same.

Slugs and SEO

Writing a good slug for your page or post can positively affect your SEO. It allows you to do the following things:

Include your keyword in the 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.

Create user friendly URLs

The URL is also one of the things that people see in the 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=613458, even though that’s the slug that WordPress creates by default.

Find out more about creating SEO-friendly URLs »

How to optimize your slug

What are the things you need to think of when constructing the right slug for your post or page? Let’s go over four steps of optimizing your slug:

  1. Include your keyword in the slug
    This is probably a no-brainer, but for the record: your keyphrase should 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:The 'keyphrase in slug' notification in the Yoast plugin

  2. 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 the slug to clarify what your page is about, but usually, you can leave them out. We have written a tad bit more on these words in our WordPress SEO article.Slug without function words

  3. 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 I manually reduced it to “slug”. Make sure the slug 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. For example: the slug for this article is ‘slug’, which is very specific. Now, we’re not going to write another article with “Slug” as a topic. This informative article is the central point for information about slugs on our website. But if this were just an additional post, and we were planning to write a main article later, we’d have a problem. You’ll understand why: because the slug “slug” would already be taken. So, do consider the page’s level or position on your website.Reduced amount of words so slug is more focused

  4. Keep it short and descriptive

    The URL of your page is shown in Google search results. Not always, sometimes it’s for instance replaced with breadcrumbs (awesome). Don’t include too much information if you intend to reuse the URL for article updates. Be careful adding dates and such to your slug, as these will instantly give away when content was originally published.
    For example: in the image, you can see an article the title mentions 2018, but the slug doesn’t. That makes for easy updating so the article is still valid in 2019 and on!
    Another reason to keep if concise: a short slug, that comes right after the domain, allows Google to show keywords in its mobile search result pages as well.techradar mindmap slug

A word of warning: it’s best to take these steps before publishing your post. If you think of a better slug after publishing your post, it may be tempting to change it. It’s just so easy, right? But beware: doing this means changing the URL and to avoid 404 errors, you’ll need a redirect. If that’s a problem, check out the redirect manager in Yoast SEO premium. It’ll instantly pop up so you can easily create one!

Conclusion: Your site needs good slugs

There it is! Now, you know what a slug is and what it can do to help your SEO. So, from now on, optimize your slugs with these four things in mind!

Read more: SEO basics: what does Google do? »

Make Yoast SEO & Woo work together smoothly

  • Make your products stand out in Google
  • Get more buyers to your online store
  • Make products easier to find on your site
  • Have a cleaner XML sitemap & more
More info

19 Responses to What is a slug and how to optimize it?

  1. mohammmad santo
    mohammmad santo  • 3 weeks ago

    how many keywords I can use per post in the free plugin

  2. Ajmal
    Ajmal  • 3 weeks ago


    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?

    • Melina Reintjens
      Melina Reintjens  • 3 weeks ago

      Hi Ajmal!
      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!

  3. Jorge Tasse
    Jorge Tasse  • 3 weeks ago

    How many keywords can I use with yoast premium per post ?

    • Hanneke
      Hanneke  • 3 weeks ago

      Hi Jorge,

      With Yoast SEO premium you can use 5 keywords per post!
      Thanks for asking.

  4. Karina
    Karina  • 3 weeks ago

    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?

  5. webcodetree
    webcodetree  • 3 weeks ago

    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.

    • Melina Reintjens
      Melina Reintjens  • 3 weeks ago

      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!

  6. James Martin
    James Martin  • 3 weeks ago

    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?

    • Melina Reintjens
      Melina Reintjens  • 3 weeks ago

      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 :)

  7. vishnu pratap singh
    vishnu pratap singh  • 3 weeks ago

    What is the word limit of slug?

    • Melina Reintjens
      Melina Reintjens  • 3 weeks ago

      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!

  8. Valencio Caccaire
    Valencio Caccaire  • 3 weeks ago

    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?

    • Melina Reintjens
      Melina Reintjens  • 3 weeks ago

      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.

  9. ritzgupta
    ritzgupta  • 4 weeks ago

    is there any ideal length for slug..?

    • Melina Reintjens
      Melina Reintjens  • 3 weeks ago

      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!

  10. Mathukutty P V
    Mathukutty P V  • 4 weeks ago

    Still confused about the difference between slug and url. Is there any difference or both are same only?

    • Hanneke
      Hanneke  • 4 weeks ago

      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!