A Straight-Forward Guide To WordPress Slugs

Last Updated on January 13, 2023 by 13 Comments

Editorial Note: We may earn a commission when you visit links on our website.
A Straight-Forward Guide To WordPress Slugs
Blog / Tips & Tricks / A Straight-Forward Guide To WordPress Slugs

When using WordPress there are so many things one might choose to learn and master that some of the most basic elements of your site can be overlooked. Especially the parts that are a bit dry and not the least bit glamorous.

Like this post’s topic: The Slug.

What is a Slug?

A WordPress slug is nothing more than a few words, which you choose, to describe a post, page, category, or tag within WordPress. These words then appear as part of the URL (or Permalink) directing visitors to that content.

Here’s a quick example:

WordPress-Slugs-first-example

The title of this post is: A Straight-Forward Guide to WordPress Slugs

The automatically generated slug (underlined portion) for this post was: https://www.elegantthemes.com/blog/tips-tricks/a-straight-forward-guide-to-wordpress-slugs

The manually edited slug (as pictured above) is as follows: https://www.elegantthemes.com/blog/tips-tricks/wordpress-slugs

As you can see, the concept is extremely simple. But its implications are also extremely important as you will see in the section on optimization below.

Where Do Slugs Appear in WordPress?

Before we get into optimization, lets take a moment to identify all of the places within the WordPress admin where slugs are created; there are four.

Posts & Pages

The first two places are probably the most obvious: posts and pages. As you just saw in my example above, WordPress automatically generates a slug for every post or page you create based on the title you write in the title box.

You are then able to edit and save the version that you prefer before publishing. Which, by the time you’re done with it, may be altogether different than the post or page title. Something we’ll get into in more detail in the optimizing section below.

Categories & Tags

The final two places within the WordPress admin where you can create slugs are the Categories and Tags submenu pages.

WordPress-Slugs-Categories-Example

In both cases the form looks the same. You type the name of your category or tag in and then enter your preferred slug beneath it. The slugs has to be lowercase and with dashes instead of spaces.

Now that we know where to go to create slugs, let’s talk about how to get the most out of them.

Tips for Optimizing your WordPress Slugs

Like most things with WordPress, there are usually many ways to accomplish a given task all at varying degrees of efficiency and effectiveness. Or in simpler terms: doing something isn’t the same as doing it right. Or best.

With that in mind, we’re going to drill down into some best practices for creating slugs–one of the simplest things one can do in WordPress. But also one of the most important things to do right.

The decisions you make when creating a slug are likely to appear in every single link you generate. So for obvious reasons of search engine optimization, page structure, etc. Let’s take a look at five simple guidelines for creating WordPress slugs.

Note: in this post I am intentionally focusing on just slugs and not the full permalink. For more information on WordPress permalinks and associated best practices, see our post A Guide to WordPress Permalinks, And Why You Should Never Use the Default Settings.

Keep Them Simple

In every instance, the slug you create is an addition to an existing permalink or permalink structure. Depending on what you choose in your permalink settings, your average url could include your site name, date, category, post/page name, and even more if you choose.

So unless you want a jumbled mess that’s hard to follow structurally and even difficult for Google and other search engines to read, keeping each element as simple as possible. Probably the best way to accomplish this is using as few and as specific words as possible.

Make Them Relevant

To me, this seems like a massive no-brainer–but it needs to be said. In an effort to simplify and shorten your slugs don’t sacrifice relevancy. Don’t cut out the words that actually describe your content best.

Speaking of which…

Target SEO Keywords

Within the confines of your simplified slug of limited words, make those words count. Target the SEO keywords that best describe your content and that you are trying to rank for.

Avoid Duplicates by Emptying the Trash

Every create a post or page and have the number “2” attached to the end of it? That’s happening because you have another post or page with the same slug and WordPress can’t let that happen. So it slaps an ugly “2” on there.

To fix this, either change your slug to something slightly different (in the case of closely related blog posts, for instance) or find the unpublished (perhaps even deleted) post and change or delete the offending slug.

If the post is already deleted, it’ll appear in the page/post trash archive. To get rid of those posts simply select all with the bulk editor and “empty your trash” by choosing the delete permanently action.

Don’t Change Them After You’ve Published Them (Unless You Absolutely Have to)

And finally, once you’ve published a link–don’t change its slug. This will alter your url, meaning any link existing on the web to that location will now be broken. Resulting in lost traffic.

However, if you absolutely must (and I suppose if your slugs are a total mess you probably should) alter your post slugs, there is a right way to go about changing them so that you don’t lose any traffic.

(It’s just a bit of a pain compared to setting things up right the first time.)

What to Do if Your WordPress Slugs Are a Mess

WordPress-Slugs-Redirection-Plugin

For those of you who may have really messed up your slugs and permalinks with clutter that is only going to hurt your content rankings in the long run, it may actually be a good idea to change your slugs so that they line up with the best practices described above. To do this, you’re going to need to either edit your .htaccess file OR use one of the following plugins. (I recommend going the plugin route.)

All three of these plugins are solid options. My personal recommendation is the first one, Redirection. They are all rated highly in the plugin repository but this one has stood the trial of a truly massive user-base (over two million) and maintains a rating of four out of five stars.

It’s also really easy to use.

Here’s what you do. Install Redirection (or the plugin of your choosing) and then navigate to its settings page. On that page you will find a tool like the one below in which you are able to paste in a source link (i.e. the link on your site you would like to redirect) and the target for that link’s redirection.

WordPress-Slugs-Redirections

You’ll need to do this for each link that needs changed. This assures that anyone clicking through to your site from an old link will not be missed traffic. Instead they will be redirected to your new link. The link that has a better structure and is also more easily located by both people and search engines.

Also, with the Redirection plugin you are able to view a log of all 404 errors on your site. Once you know which urls those errors are occurring on you can quickly make that link a 301 redirect and recapture that traffic too.

In Conclusion

Mastering the humble WordPress slug can result in some pretty great things. More organic traffic for one. But also recaptured traffic if you go ahead and take advantage of a plugin like Redirection. The best part is that this is something that anyone using WordPress can wrap their head around and get right every time. It’s a good feeling!

What is your experience with WordPress slugs? Do you have any more tips or best practices to add to the ones we’ve listed in this post? Drop us a line in the comments below and share your thoughts and stories with us.

Article Thumbnail by Albert Ziganshin // shutterstock.com

Divi

Want To Build Better WordPress Websites? Start Here! 👇

Take the first step towards a better website.

Get Started
Divi
Premade Layouts

Check Out These Related Posts

Splice Video Editor: An Overview and Review

Splice Video Editor: An Overview and Review

Updated on March 10, 2023 in Tips & Tricks

Video is a valuable form of content for social media. Unfortunately, creating quality videos is usually a long process that involves moving mobile footage to a desktop app for editing. However, mobile editing is on the rise. Apps such as Splice Video Editor make it possible to efficiently create...

View Full Post
How to Use Font Awesome On Your WordPress Website

How to Use Font Awesome On Your WordPress Website

Updated on September 16, 2022 in Tips & Tricks

When given the choice between using a vector icon or a static image, it’s a good idea to go with the vector. They’re small and fast to load, and they can scale to any size without a loss of resolution. Font Awesome is a superb library of vector icons that you can use on your websites,...

View Full Post

13 Comments

  1. Hi, Like to know what the rules are for slugs of more than 1 word.
    For instance If I have a slug called:

    medicinal plant

    I understand that I can’t have space, so should it be: medicinalplant or
    medicinal-plant or
    medicinal_plant
    I ask because i’ve read that using “-” (dash) is not a good idea because in php code it could be interpreted as minus, is this correct? do I have to join words with an underscore and then have strange urls with mixed dashes and underscores?

    Thanks for any help
    David

  2. Excellent article Nathan. Thank you. Explained well, illustrated well . . . even I understood it;-) Definitely adding this to my ‘WordPress 4 Dumb Me’ Bookmark

  3. Kudos to the illustrator. Really like the slug illustration…

    ernie

  4. Finally, I understand slugs! Thank you. I have been changing them in blog posts…but not in categories or tags.

    Very useful.

    Cheers

    Sarah

  5. Excellent article Nathan.
    I am sharing it with my WordPress Meetup group in Phoenix.
    http://goo.gl/TuQIaV

  6. Hi Nathan,

    Nice article which sums it up. And thx Irena for the mulitlanguage approach.
    Thx

  7. I have used permalinks for so long but never knew those words were called slugs! Many thanks Nathan.

  8. Got to know about the ugly 2…..
    Thanks

  9. Hi Nathan.

    Have any way to change slugs to my custom format?

  10. Hi Nathan, excellent article. I think you forgot to change the slug for this article 🙂

    I would add some details about slugs:

    – Always remove stop words and use hyphens (WordPress SEO by Yoast can automatically remove stop words)

    – Use short slugs. In order to make slugs more memorable use shorter URL slugs but containing the most important keywords of your post (2, 3, 4 or 5 keywords max).

    – Another slug in WordPress: the author slug of a user. There is a plugin, Edit Author Slug, that allows edit the author slug of a user

    – When it comes to editing slugs in non-Latin alphabet or containing non-Latin letters, a good solution is to use transliteration (a word written in a character set like the Cyrillic alphabet is transposed in another alphabet, Latin).

    How many things have slugs !!!

    (A recent article about translate slugs in WordPress: http://wplang.org/translate-slugs-wordpress/)

    Irena

    • This post slug must have been changed back from my edited version to this version by the editor. I’ll notify them. Thanks for the heads up.

  11. Nathan, I’ve lived in the Pacific NW for over 31 years now and should know more about slugs than I do. Learning more about WordPress slugs has been high on my list since moving over to WordPress.org, so thank you for clearing the air for me. Saving this to my WordPress Tips/Tricks bookmark folder.

Leave A Reply

Comments are reviewed and must adhere to our comments policy.

Get Started With Divi