Eric Isselée / stock.adobe.com
If you’re not well-versed in WordPress, there are some terms related to the platform that can leave you scratching your head and asking questions like, “What is a slug?” and “What does it have to do with my website?”
Despite the confusing name, WordPress slugs are actually quite simple to understand. They’re also a vital part of your website’s organization, navigation, and User Experience (UX), so getting a handle on them is key.
In this post, we’ll explain what a slug is in WordPress and why it’s important. We’ll also share tips for creating your own, and for troubleshooting common issues. Let’s get to it!
In This Article 📋
What Is a Slug In WordPress? 🐌
In WordPress, a slug is the last part of a URL, which indicates the location of a specific post, page, or category archive. The slug of this post is what-is-a-slug-in-wordpress.
Once you know that, the importance of WordPress slugs becomes pretty apparent. They help users access your site’s content.
[bctt tweet=”🐌 WordPress slugs are key to your site’s UX and navigation! #WordPress” username=”thewpbuffs”]
However, there are some not-so-obvious ways slugs impact your site, too. Most notably, they’re an important element of UX. If you’ve crafted quality slugs for your posts and pages, visitors can always glance at their browsers’ address bars to figure out where they are on your site:
This is especially helpful if your site is experiencing an error and not displaying your content correctly.
Additionally, search engines such as Google take page slugs into consideration when indexing and ranking content. If you’re smart about how you craft your slugs (more on that later), you can optimize them to improve your content’s visibility on Search Engine Results Pages (SERPs).
WordPress Slug Examples
In case you’re still feeling a little confused about what exactly a slug is in WordPress, we’ve listed some examples for you below. For each, the slug is the bold portion of the URL.
- https://wpbuffs.com/how-to-embed-a-pdf-in-wordpress
- https://wordpress.org/plugins/woocommerce
- https://www.newyorker.com/culture/dept-of-design/how-the-coronavirus-will-reshape-architecture
- https://blogs.blackberry.com/en/category/software-solutions/unified-endpoint-security/blackberry-persona
- https://www.mercedes-benz.com/en/lifestyle/travel
As we mentioned earlier, slugs can be used not only for posts and pages, but also for categories. This is especially common on content-heavy sites such as blogs, as well as e-commerce stores. Here are some examples of category slugs:
- https://blogs.blackberry.com/en/category/software-solutions/
- https://www.newyorker.com/culture/
- https://www.mercedes-benz.com/en/lifestyle/
Hopefully, you feel pretty clear on the concept now. That means it’s time to start writing your own slugs.
4 Tips for Creating Quality WordPress Slugs 🖋
WordPress enables you to easily create your own custom slug for every post, page, and category on your site. Here are some guidelines to help make sure yours are in tip-top shape.
1. Make Sure the Slug Reflects the Page’s Content
As we already mentioned, one of the benefits of slugs in WordPress is that they can tell visitors what the current page is about. However, this only works if your URLs include words that reflect the content of their posts or pages.
Some sites use random strings of numbers and letters as their slugs. This eliminates all the potential UX benefits the element can provide:
So, when creating your slugs, make sure they describe what the corresponding content is about. For this reason, slugs are often very similar to the titles of their posts and pages.
2. Separate Words With Dashes
While one-word slugs are common enough, you’ll often need to incorporate several terms to craft the most effective URL. When doing so, make sure to separate them with dashes, like so:
This makes it easier for visitors to read your slugs. It can also prevent unfortunate combinations of letters from two words that form less-than-savory terms when placed right next to one another.
3. Incorporate Keywords to Improve Search Engine Optimization (SEO)
As we briefly mentioned earlier in this post, your WordPress slugs can affect your content’s visibility in search engines. URLs are a minor ranking factor for Google. Incorporating keywords into your slugs can help demonstrate your page’s relevance to certain subjects.
In addition to improving UX, SEO is a smart reason to create and use category slugs in your URLs in addition to post and page slugs. This provides more opportunities to incorporate keywords and signify your site’s relevance to certain topics.
However, make sure that keyword optimization doesn’t come at the expense of clarity. It’s important that users can still understand what your page is about by looking at the slug, and that it isn’t just stuffed with search terms.
Additionally, a well-optimized slug isn’t likely to make up for a low-authority domain. It’s important to make an effort to establish your site’s overall credibility if you want to make significant improvements in terms of search engine rankings.
4. Keep Slugs as Short as Possible
In most cases, a short slug is preferable to a long one. This makes the URL as a whole easier to remember, which can come in handy if returning users want to quickly type in the address of a specific page or post instead of navigating through your site:
That said, you don’t have to limit yourself to one-word or even two-word slugs. Always keep the first point above in mind and ensure your slug makes sense and describes the contents of the post or page.
How to Change a Slug In WordPress 🧐
If you’ve been publishing content on your WordPress site for a while now but are only just getting the hang of slugs, you may want to change some of your old ones to improve them. Additionally, new posts and pages generate default slugs, which aren’t always well-optimized.
Fortunately, you can change slugs quite easily. For post or page slugs, open the content in question in the WordPress editor. Then look for the Permalink section in the Document sidebar:
Expand it, then type your new slug into the text field:
Save or update the post or page, and your new slug should now be in place.
If you’re using the Classic Editor, the process is different. First, click on the Edit button next to the permalink under the title:
Then, enter your new slug and click on OK:
To change a category slug, go to Posts > Categories and click on Edit under the relevant category:
Modify the slug in the relevant field, then click on the Update button:
Note that changing slugs of published posts and categories will break any existing links to the corresponding post, page, or archive. Update them where you can (e.g., your own site, social media), then set up 301 redirects to make sure users are forwarded from any lingering broken links to the right address.
[bctt tweet=”🔗 While you can easily change your WordPress slugs whenever you want, this may result in broken links. Don’t forget to set 301 redirects! #WordPress” username=”thewpbuffs”]
Changing WordPress Default Slugs and Permalink Structure
Another way you can change your slugs in WordPress is to modify your permalink structure. We covered this topic in detail in a previous tutorial. You’ll find all the relevant options in Settings > Permalinks:
Changing your permalink structure enables you to select how WordPress will generate default slugs to apply to your posts and pages. Generally speaking, the Post name option tends to produce the best results, since your title likely includes relevant keywords and describes what the post is about.
Like updating slugs for published content, changing your permalink structure will break links to your existing posts and pages. If you choose to do so, you’ll need to set up 301 redirects for each piece of content on your site.
What to Do If Your WordPress Slug Is Not Working 🤷🏽♀️
Slugs rarely cause issues on WordPress sites. The main problem you may run into when working with them is if you’re trying to change the address of a new post or page, and the field to enter your new slug is missing:
This happens because posts and pages must be saved at least once in order to update the slug. Simply click on Save Draft at the top of the editor to fix this problem.
On the other hand, there are many things that can go wrong with WordPress permalinks. Generally, if there’s a problem with them, you’ll see a 404 Error page:
Your first course of action in this situation should be to check if you’ve clicked on a broken link. If not, your .htaccess file, which controls your permalinks, may be corrupt. You can fix this by resetting it.
To do this, you’ll need some knowledge of File Transfer Protocol (FTP) and an FTP client such as FileZilla. Connect to your server, then find your .htaccess file in your public_html directory:
Then, disable this file by renaming it. Something like .htaccess_old works best so that you can still identify it later if need be:
From here you have two options. First, you can use the default .htaccess code from the WordPress Codex to create a new file and upload it to your server. Alternatively, you can change your permalink structure as we described above. This will automatically generate a new .htaccess file.
In either of these cases, any customizations that have been made to your .htaccess file will be lost. The third solution is to access an uncorrupt version of the file from a backup of your website and upload it via FTP. This should preserve any unique functions, assuming they were in place at the time of the backup.
Wrapping Up ⏰
Understanding what a slug is in WordPress isn’t as intimidating as it may initially seem. Once you know where to find the relevant settings in WordPress, creating and changing your post, page, and category URLs is pretty straightforward.
In this post, we provided you with tips and tools to help you accomplish these tasks, including incorporating keywords into your slugs for SEO. We also discussed how to fix problems with your slugs that might come up.
Want help changing your slugs in WordPress or resolving permalink errors? At WP Buffs, we provide WordPress Care Plans that include content updates as well as emergency support. Check them out today!
Want to give your feedback or join the conversation? Add your comments 🐦 on Twitter!
Featured Image Credit: Unsplash.
GIF via GIPHY.