While working on your WordPress website, you must have come across the word “slug,” and you wonder, “what is a WordPress slug?“.
In this post, I will explain in detail what is the meaning of a slug in WordPress. I will also elaborate on the difference between a category slug in WordPress and the post slug.
Additionally, I will highlight the difference between a permalink and a slug so there is no confusion in your mind over these two similar but unique concepts.
Also, did you know that a slug has tremendous SEO benefits for your website? Read this entire post to discover how you can optimize the slug to score quick SEO wins.
What is a WordPress slug?
A slug is that part which follows your website address in the URL (permalink). So if your address is www.myblog.com, then anything after the forward-slash (/) is the slug.
Let’s say you have a page on your site www.myblog.com/my-page. Then, “my-page” is the slug of this page.
Now that you have understood that the slug is part of the permalink (URL), you should no longer be worried about comparing a slug to a permalink in WordPress.
Whenever you edit the slug, it means that you’re changing your permalink or URL and vice-versa. The only point is that the permalink contains two parts: the domain address and the slug.
So, when we talk of changing the permalink, it usually means editing the slug unless you’re migrating your website to a new domain address. In this instance, the slug will not change but only the domain address will be modified.
How to edit the WordPress post slug
Once you know the meaning of the slug in WordPress, its time to see it in action and be able to edit it.
To do this, you should create a new post or a page in WordPress. Next, add a title and save the draft.
The link that appears at the top of the post or page title is called the permalink (URL), and within this permalink, the part that appears after the site name is the slug.
Permalink is the short form for permanent link. It is permanent since it will not change even after you edit the post unless you manually modify the permalink by clicking the Edit button on the right.
But you should NEVER change your slug or permalink on the fly since it can have disastrous SEO consequences besides resulting in poor user experience as the old URL will throw up a 404 page not found error.
Rather, if you need to change your permalink for whatever reason, you should insert a 301 redirect to the new URL.
Notice that the slug is all lowercase and different words are separated by a hyphen.
This isn’t all. There are some SEO benefits of creating the right slug or permalink structure, in general. I will talk about this in a minute.
First, let’s see…
What is a category slug in WordPress?
Now that you know the meaning of a slug, you should familiarize yourself with the category slug in WordPress.
If you navigate to Posts>Categories in the WordPress admin dashboard, you will notice the option to add a new post category.
Here you can add a new category with its name (I have added WordPress Themes) along with its slug (wordpress-themes).
I can either add the slug myself or if I click on the Add New Category button, the slug will be created automatically.
You should note that a WordPress category and post slug is always lowercase and can only contain letters, numbers, and hyphen.
The hyphen separates two or more words in the category name.
Even if you try to enter special characters manually in the slug, these will be deleted by WordPress. You can try it out yourself.
Now let’s say you wish to add your category slug in the WordPress post permalink. This is quite easy to achieve.
Jump to Settings>Permalinks. By default, the permalink is set to post-name.
But since we wish to add the category slug to our permalinks, we need to select the Custom Structure.
There are number of available tags that you can add to your permalink but you should just focus on the category tag for now.
Since you want to insert the category slug before the post slug, you should first deselect the post tag by clicking on the %postname% tag. Then select the %category% tag followed by the %postname% tag.
Your permalink structure should resemble the one in the above image which is https://passionwp.com/%category%/%postname%/
But before you add the category slug to your WordPress post permalink, you should know the following:
- Permalink changes are site-wide. So, it is not advisable to change your permalinks if your WordPress website is well established.
- If you change the post category in the future, it will also change the category slug and, resultantly, your site permalinks will also change.
For these reasons, I would advise against adding category slug in your WordPress permalinks.
Scoring quick wins with the WordPress slug for SEO
In the beginning, I promised I would share tips to score quick SEO wins using the WordPress slug. Read on to know how to optimize the slug and permalink to get noticed by search engines and rank higher.
By default, WordPress turns your post and page titles into URLs. So, if your post title is “the best dog food brands to check out”, then your URL or permalink will be www.yoursite.com/the-best-dog-food-brands-to-check-out/
This URL is too long and sub-optimal from an SEO standpoint.
SEO expert Brian Dean explains that your permalink should:
- 1Be short and simple.
- 2Contain the primary keyword.
- 3Use hyphens to separate words.
Using these principles, we should change the slug in the above dog food example to www.yoursite.com/best-dog-food-brands/
This is because the primary keyword for this post would be “best dog food brands”. Brian Dean also found strong correlation between short URLs and search rankings.
That’s why you should edit your permalink to keep it short and sweet, and containing your target keyword.
I have already explained how you can easily edit the post slug to modify the permalink. Additionally, while editing the slug, remember to remove stop words like the, and, of, etc. from the slug.
This will help search bots to easily index your post. Also, since your post slug contains your main keyword, it conveys the right message to the search spiders and searchers on what the post is about.
Now that you have seen how to edit the WordPress category and post slug, you should implement what you have learned on your website. And while you’re doing so, please leave a comment if these tips helped you to optimize your post and category slug.
Download the WordPress SEO eBook
Go from WordPress SEO Zero to Hero in no time. Also receive 2 Bonus PDFs with this free eBook.
Give it a try. You will thank yourself later.
- GeneratePress Free vs Premium: Which Option is Right for You? - May 28, 2021
- Fixed: This Site Can’t Be Reached Error in WordPress - May 13, 2021
- 9 Ways to Fix WordPress HTTP Image Upload Errors - April 24, 2021