WordPress

What is a Slug in WordPress?

November 20, 2020

Are you wondering what the term ‘slug’ in WordPress represents? You can rest assured that you aren’t the only one with the same question.

So, what is a slug in WordPress? How do I use it? How do I set it up properly? Why is it so important?

This article will guide you through the process of understanding slugs and learning how to edit them to help you achieve your online goals.

Still copying content into WordPress?

You’re doing it wrong… say goodbye forever to:

  • ❌ Cleaning HTML, removing span tags, line breaks, etc.
  • ❌ Creating your Table of Contents anchor ID links for all headers by hand,
  • ❌ Resizing & compressing images one-by-one before uploading back into your content,
  • ❌ Optimizing images with descriptive file names & alt text attributes,
  • ❌ Manually pasting target=“_blank” and/or “nofollow” attributes to every single link
Get 5 free exports

What is a Slug in WordPress?

A slug in WordPress is the text that comes after the domain name. For instance, the words “wordpress slugs” in “www.domain.com/tutorials/wordpress-slugs.” To all intents and purposes, a WordPress slug is a permalink part that leads to a particular piece of content.

Slugs are an important aspect of SEO (Search Engine Optimization). It helps your page end up listed in the top results in search engines. It also helps returning visitors navigate to a particular page/post manually and quickly.

Why Do Slugs Matter?

Well, let’s start off with the search engine example. You may not know this, but search engines actually look at slugs, which is why they’re relevant to SEO.

Then, there’s the aspect of user-friendliness. Some users will actually type in an entire URL if it’s their go-to address.

A non-optimized WordPress slug is often nearly impossible to remember, and too much of a drag to type in manually.

Examples of WordPress Slugs

A Single Slug

Single slugs are the most basic slug type that you’ll find in WordPress. Essentially, they consist of the website URL plus a single slug that leads to the page in question. They look something like this: www.wordpress.com/slug-example.

Back-to-Back Slugs

Of course, you can have multiple slugs listed in the back-to-back fashion. The more pages you navigate through on a website, the more slugs will be added to the permalink URL. It’s always the last slug that dictates the most precise location on the web. Here’s what back-to-back slugs tend to look like: www.wordpress.com/slug-example/sub-slug-example/yet-another-example.

Default Slugs

WordPress will automatically assign a slug to any WordPress post or page that you make. Sometimes, these slugs will be SEO-friendly. Other times, they will contain various symbols, making them less than ideal. They look something like this: www.worpress.com/post-slug/#:~:text=The%20post%20slug%20is%20the,%25’%20in%20the%20URL%20structure.

WordPress Slugs Use Cases

Keywords

Keywords are among the main aspects of SEO. They are used to allow search engines to better rank your content. Keywords are best used with little symbols/words in between them. Therefore, if your target keyword is ‘What is a slug in WordPress,’ you should try keeping the phrase together as much as possible (although some exceptions do exist). ‘What-is-a-slug-in-wordpress’ is generally considered a good keyword. This is what slugs allow us to do.

Web Development

No matter how into programming and coding you are, when developing web content, you want to keep things as plain as possible. Rather than remembering a variety of codes or having to navigate through a website that you’re developing, using a convenient slug will help you get there quicker.

Quick Access

Similarly, some of your frequent users might want to get to a certain webpage manually and quickly. Memorizing slugs will help you to do so.

How to Set WordPress Slugs: A Step-by-Step Walkthrough

Fortunately, setting slugs in WordPress is very straightforward. Well, at least if you know what you’re doing. There are two essential rules that you always need to keep in mind here.

First of all, as you may or may not be aware, there are no spaces in URLs. Dashes are used instead. So, a slug for a page title like ‘Make Orders Online’ will appear as ‘make-orders-online’ in the URL.

The second rule is that there are no uppercase letters in URLs. Only lowercase letters are allowed.

Now, WordPress will automatically correct this for you. But it’s better that you understand these rules before proceeding.

There are a couple of slug types to consider. Here’s how to set slugs for different types of WordPress content.

WordPress Posts

Setting a slug for your WordPress post is very easy – you do it while writing/editing the post. To set the slug for your post, just go to the Title box and find a permalink URL below it. If you can’t seem to find the permalink, you should keep in mind that you need to set the title before you continue. Once you’ve set the title, the permalink will appear, and you’ll be able to edit the slug by using the Edit button. Once you’re done editing, select OK.

slug example

WordPress Pages

Customizing a slug for your WordPress page is also very simple. Similar to the posts, you’ll find the permalink URL for pages under the name box of that page. Go to Edit, customize the slug, and select OK.

slug example

Category and Tag Slugs

This is a bit more complicated, but it’s nothing to be scared of. Setting slugs for tags and categories is also very straightforward. It’s also very important, because your frequent visitors may want to remember the slug and type it in fast, instead of having to go through various pages on the website.

So, you’ve created a category. Now, you’re going to have to go back to the Posts screen and select Categories. Then, go to the category in question on the list and select Edit. Next, use the slug of your preference and select Update. The principle is nearly identical for tags. In the Posts screen, select Tags and use the same principle as the one mentioned above.

As a rule of thumb, you’ll want to add categories and tags first and change the slugs later – unless you don’t mind a ton of back-and-forth.

add a tag

WordPress Slug FAQs

What is a slug name?

The term ‘slug’ is used in web publishing to signify the part of an URL permalink that IDs the resource/page in question.

How do I find the URL of a slug in WordPress?

To get an URL page link from a slug, use the ‘get_permalink( get_page_by_path( ‘contact’ ) );’ or

‘get_permalink( get_page_by_title( ‘Contact’ ) );’ function.

Why is it called a URL slug?

The word ‘slug’ is used in the news media; they’re short name forms for articles, for internal use. This is why the term is now frequently used in WordPress as well.

What does a permalink look like?

Permalinks are the full URLs of websites, webpages, posts, etc. To see what a permalink looks like, just go to any webpage online and check out the URL box.

Conclusion

Now that you know what slugs in WordPress represent, hopefully, you’re clear on how important they are, even more so, when you consider the fact that they’re very easy to set and can be hugely useful, both for SEO and the user experience.

Kevin Kessler
Kevin J. Kessler is a published author of five fantasy novels, a professional wrestler, and a puppeteer (not all at the same time). Kevin is a content writer at Codeless.
Kevin Kessler
Kevin J. Kessler is a published author of five fantasy novels, a professional wrestler, and a puppeteer (not all at the same time). Kevin is a content writer at Codeless.