Slugs. Slimy little critters that have a nasty habit of getting into your vegetable garden… Or maybe not! In this post, we’re talking about a different kind of slug, and that’s the slug that forms part of the address (or URL) of the individual pages and posts in your WordPress website.
A slug is unique to each post, page or archive, and will tell a browser exactly where to go. But there’s more to them than that, and there are ways you can use them to boost your site’s search engine optimisation (SEO) and user experience (UX).
So let’s start by examining what a slug is and then move on to looking at how you can optimize your slugs in WordPress.
Slugs Versus Permalinks
You may have heard of another term relating to links in WordPress, and that’s permalinks.
So what’s the difference between a permalink and a slug?
The permalink is the entire link to a post. So the link to a post on an example website might be https://example.com/what-is-a-slug-in-wordpress/.
That full link is the permalink. It consists of three parts:
- The protocol: https://
- The domain name: example.com/
- The slug: what-is-a-slug-in-wordpress
The permalink in WordPress refers to that link but is also a unique link you can fetch in your theme template files using the the_permalink() function.
For the purposes of this article, we’re looking at slugs. The slug in that link is what-is-a-slug-in-wordpress.
You can see that the slug is based on the title of the post.
In WordPress, you can opt to use ‘pretty’ permalinks based on the post title, or ugly permalinks based on the post ID. I’ll show you why it’s better to use pretty permalinks and how to optimise your slugs for SEO and UX.
Slugs and SEO
Slugs are very important for SEO. In addition to the post title itself, they tell search engines what your post is about, and should include keywords that you are aiming to rank for.
So if you used slugs that consisted only of the post ID (e.g. post-3456), that wouldn’t be very helpful to search engines.
But if you use a slug that is based on the post title and includes keywords, it will help your post to rank more highly.
I’ll show you how to edit the slug for an individual post or page to include keywords shortly.
Slugs and UX
Slugs also have a role to play in UX. If you want users to remember the link to a post and be able to use it again without copying and pasting the post, or without searching for it, you’ll need to create a slug that’s short and memorable.
So for a post on slugs I might use something as simple as example.com/wordpress-slugs. You’d have no trouble remembering that and knowing what it was about (unless you were interested in slimy critters, in which case you might get confused).
To create such a memorable slug, I could edit the slug in the post editing screen for my post. If my site is set up to have an extra folder in its domain structure and the link to the post is example.com/blog/what-is-a-slug-in-wordpress, I might use a redirect to redirect example.com/wordpress-slugs to it. But the slug that search engines see would be the first one. This means you can create a slug for your post that includes all your keywords for SEO, and also create a short slug for users that redirects to that.
How to Optimize Slugs in Your WordPress Site
There are two ways to optimize the slugs in your WordPress site. The first is to configure your permalink settings and the second is to edit the slug setting for an individual post. You can’t do the second one unless you do the first, so let’s look at that first.
Configuring Permalink Settings
To access Permalink settings, go to Settings > Permalinks in the WordPress admin screens.
WordPress gives you six options:
- Plain: This is based on the post ID. While it’s short, it’s not memorable and not at all pretty. I wouldn’t advise using this option.
- Day and name: This is prettier, as it includes the name of the post as well as the date it was created. But it is quite long, so not so good for UX.
- Month and name: This is shorter than the day and name option and still includes the post title, so might be a compromise if it’s important that your URLs include the date, or if you have duplicate content each year and need to differentiate it. Don’t use this if you want your content to be evergreen.
- Numeric: This option uses the post ID and is ugly, so won’t benefit your SEO or UX.
- Post name: This is the prettiest option. It’s the best for SEO and for UX, and is what most WordPress sites use.
- Custom Structure: Use this if you want to customize the structure. For example you might want to insert /blog/ between your domain name and the slug. Or you might want to include both the post name and the post ID in slugs. Use the tags provided by WordPress to configure this, making sure you copy them correctly.
The Permalinks setting screen also lets you configure the links used by archive pages for your tags and categories. These aren’t slugs in the strictest sense but you might also want to configure those, changing the default category to something else. This could be beneficial for UX or SEO if you have specific words that are meaningful to your users or that you want to rank for.
So instead of example.com/category/category-name, you might prefer to use example.com/services/category-name if your categories are actually services, or example.com/department/category-name if you’re running a store.
To enable pretty permalinks, go to the permalink settings screen and choose the options you want. Then click the Save changes button to save your configuration. Once you’ve done that, you can edit the slug for an individual page or post.
Editing Individual Post and Page Slugs
Once you’ve configured your permalinks settings, you can use the options on the editing screen for an individual page or post to make the slug more memorable or SEO-friendly than the default.
By default, WordPress creates a slug that’s based on the title of the post. So if I create a post called 20 Ways to Make Your WordPress Site Soar, the slug will be 20-ways-to-make-your-wordpress-site-soar.
To see this in action, create a new post (Post > Add New), give it a title and save it as a draft by clicking the Save Draft link.
Now click on the title of the post in the post editing screen. The full URL of the post will be displayed above the title, including the slug.
Now click the Edit button next to the link and edit the slug (the last part of the link). You might want to make it shorter, so I could change mine to make-wordpress-soar:
Or you might want to edit it to include a specific keyword that you want to rank for in search engines, such as ‘WordPress performance’. In that case, you could change it to 20-ways-to-boost-wordpress-performance:
Note that if you wanted to rank for the search term ‘wordpress performance’, you really should edit the title of the post as well to include that term, as that will have an even bigger effect not only on your ranking but also on the number of people clicking through to your site after they find it.
Once you’ve made the changes you need to, save your post by clicking the Publish button.
A Word of Caution When Editing Slugs
Editing slugs is very easy to do. If you have a post that isn’t performing, you might be tempted to go into WordPress and edit its slug as a way to fix it. But if you do that, the permalink will change, which means that any existing link to the post (using its old slug) that you’ve shared in the past will break.
You can fix this by installing a redirection plugin and setting up a redirect from the old URL to the new one. In fact, when configuring the redirect in the plugin settings, all you’ll have to do is use the old and new slugs and the plugin will do the rest for you.
The Redirection plugin is free and makes redirects easy. But if you want to be able to set up more complex redirects, you could try one of the premium plugins available at CodeCanyon.
Some of the best redirection plugins on CodeCanyon include:
- 5 Second Redirect, which keeps stats on your redirects so you can see their effect.
- SEO Redirection Pro, which helps you optimize your redirects for SEO.
- WP GeoIP Country Redirect, which will automatically redirect to country-specific URLs based on location.
- WordPress Ultimate Redirect Plugin, which includes automatic reducers when you edit slugs and much more.
Best Practice For WordPress Slugs
Sometimes you’ll need to find a balance between SEO and UX when configuring your slugs. But it’s worth understanding some principles which will help you adopt best practices with your slugs. These include:
- Use pretty permalinks to ensure your slugs are text and not post IDs, and that they are as short as possible.
- Edit your slugs to include search terms if you want to optimize them for SEO. These should also be in the post title—meaning that you don’t actually need to edit the slug if you start with the right title!
- Make slugs short and memorable for UX. Remove filler words like ‘and’ and ‘of’, as well as numbers for list articles.
- If you edit the slug of an existing post, make sure you set up a redirect so the old slug will redirect to the new slug.
- If you change the title of a post, the slug won’t automatically change. You’ll have to edit it manually (and set up a redirect if it’s an existing post).
Summary
Slugs are an important part of WordPress. As part of the permalink, they make each post and page unique so it can be correctly displayed by browsers.
But optimised slugs will also enhance your SEO and your UX. If you configure your slugs so that they work harder for your site, you’ll get more visitors and provide a better experience for them.
The Best WordPress Themes and Plugins on Envato Market
Explore thousands of the best WordPress themes ever created on ThemeForest and leading WordPress plugins on CodeCanyon. Purchase these high-quality WordPress themes and plugins and improve your website experience for you and your visitors.
Here are a few of the best-selling and up-and-coming WordPress themes and plugins available for 2020.
-
WordPress Themes16+ Best WordPress Themes for Writers and Authors (2020)
-
WordPress17 Best WordPress Slider & Carousel Plugins of 2020
-
WordPress20 Best WordPress Calendar Plugins and Widgets
-
WordPress Themes23+ Best Responsive WordPress Themes (For Sites in 2020)
-
WordPress24 Best WPBakery Page Builder (Visual Composer) Addons & Plugins of 2020
-
WordPress Themes29+ Best WordPress Directory Themes to Make Business Websites (2020)
No comments:
Post a Comment