Breaking down a WordPress slug
To understand what a slug is, let's dissect the different parts of a URL. Let's take this post's URL, for example.
https://blog.hubspot.com/website/what-is-wordpress-slug
To understand what a slug is, let's dissect the different parts of a URL. Let's take this post's URL, for example.
https://blog.hubspot.com/website/what-is-wordpress-slug
From left to right, we have:
-
The scheme — you'll usually see https:// (or http:// if the page isn't SSL-encrypted).
-
The subdomain, like "blog" in this URL or simply "www" in others
-
The second-level domain — the name of the website ("Hubspot" in our case)
-
The top-level domain, which is most often .com, but could be .org, .net, .io, etc.
-
The subdirectory, which comes after the first slash. This indicates what subsection of the website we're on. A URL can have one, multiple, or no subdirectories. In this post, the subdirectory is "website" because we're on the Website section of the HubSpot blog.
-
The slug, which comes after the second slash and identifies the specific page within the subdirectory.
Before we walk through how to change the slugs on a WordPress site, let's review some best practices for optimizing them.
WordPress Permalinks vs. Slugs
With WordPress, the terms "permalink" and "slug" are sometimes used interchangeably when referring to URLs. But, yes, there is a difference. When you use a permalink, that is a permanent URL of a post or page on your website. A permalink should not change once the page/post is live, hence the name.
Your slug is simply a portion of your permalink. More specifically, it's the name of the page or post at the end of the permalink that makes it easy for readers and search engines to understand what the post/page is about.
How to Optimize a URL’s Slug in WordPress
Designing for humans — and bots — should be a guiding principle for everything you do as a site owner, and that includes optimizing a URL's slug in WordPress. Consider the following URLs:
https://blog.hubspot.com/website/what-is-wordpress-slug
…versus…
https://blog.hubspot.com/website/post-id?=5726fjwenfkd
Which one, as a reader, would you rather click on? Which would instill the most confidence about the content you're about to digest? Probably the first one, which is why slugs make more of a difference to the user experience than you might think.
To optimize for search engine bots as well as your readers, follow these best practices:
Include 1-2 keywords.
Don't try to target all your keywords — include the main phrase you want to rank for in the slug. By doing this, you'll help both search engines and readers deduct what the post is about. The general syntax should be as follows:
websitename.com/topic-mentioned-here
Match the title (but don’t replicate it).
It's wise to keep the slug similar to the title — but not exactly the same. For example, if your post is titled "The 10 Best Flowers for Spring," your slug could be: best-spring-flowers. It's unnecessary to include certain words. Besides, post titles are usually much longer than slugs should be. Titles also use spaces and title case, whereas slugs should use hyphens or underscores between words and be all lowercase.
That being said, your title and slug should still connect. Say your post is titled "Our Favorite Dachshund Puppy Photos." If your URL is "how-to-get-cheap-plane-tickets," bots and readers are going to be confused by the difference in content and take it as a cue they're in the wrong place.
Remove unnecessary words.
You can make slugs more readable by omitting pronouns, articles, and prepositions. These are known as stop words and are generally ignored by search engines anyway. A good rule of thumb is if readers can fill in the gaps and make sense of the slug without certain words, you should omit them.
Now that we've covered these tips and techniques, let's see some real ones. Here are some examples of HubSpot blog post titles and their URL slugs:
Title |
Slug |
30+ Best Blogging Tools to Grow Your Blog in 2023 |
best-blogging-tools-grow-blog |
The Anatomy of a Search-Friendly URL [Infographic] |
url-structure-search-friendly |
Serverless Functions: Your Website's New Best Friend |
serverless-functions |
9 Squarespace Alternatives & Why You Might Want Them |
squarespace-alternatives |
With these best practices in mind, let’s walk through the process of changing a URL slug in WordPress.
How to Change a URL Slug in WordPress
By default, WordPress uses the “plain” permalink structure, as shown below.
Because the plain structure does not contain keywords, it is not an SEO-friendly structure.
Changing this default permalink structure is an important step to make your WordPress blog SEO-friendly. You can do so by navigating to Settings > Permalinks and selecting another option. We recommend “Post name” because it is the shortest slug option while still including relevant keywords.
Note that it’s important to change your permalink settings before launching your website if possible. If you change your permalinks after your site goes live, you’ll have to set up redirects from your old URLs to your new ones. Fortunately, there are plenty of redirect WordPress plugins to simplify this process.
Once you receive a notification that your permalink structure has been updated successfully, you can edit the slugs of individual posts and pages on your site. Let’s walk through the process step by step.
1. Navigate to Posts > All Posts to edit an existing draft or Add New to create a new draft. You can follow these steps for Pages as well.
2. If you navigated to All Posts, then scroll to the draft you want and click Edit.
3. On the right-hand side of the screen, click the optional control next to Permalinks to open the dropdown menu.
4. Edit the slug, then click Save Draft in the toolbar at the top of the screen.
You can repeat this process for all your posts and pages moving forward. This ensures you’re creating SEO-friendly URLs that delight search engine bots and your site visitors.
WordPress Slugs: Don’t be slow to update them!
Changing your URL slug isn't difficult, but it's essential if you want a WordPress website that both humans and search engines will love. And while your WordPress URL slug might not seem significant in the scheme of things, it is.
A Clean URL distinguishes a novice website owner from an experienced one. Not only are clean URLs better for SEO, but they also make your website look more legitimate and give visitors a better idea of how your website is structured.
Editor's note: This post was originally published in June 2020 and has been updated for comprehensiveness.