WordPress uses various jargons that is difficult for new users to understand. Taxonomy, permalink, slug and some of the terms used frequently in WordPress documentation and tutorial articles. You can check out the WordPress glossary page to understand the meaning of frequently used terms in WordPress world. In this article, we will explore in more detail about what is slug in WordPress, its SEO importance, how to change the slug and how it will impact your SEO.
What is Slug?
A webpage URL which you use to access the page in a browser contains multiple components:
- HTTP or HTTPS protocol
- With or without WWW subdomain
- Primary or top-level domain
Below picture indicates the components in an understandable manner:
Since the protocol and domain parts are always fixed for a WordPress site, slug is the only component changed for each page to have a unique URL structure.
How Slug is Generated in WordPress?
Now that you know what is slug in WordPress, but the above URL example is not a standard structure for all WordPress sites. You may find some WordPress sites have different URL structure which contains custom parameters like year and month. WordPress automatically generates the slug for each page based on the below settings:
- Permalinks setup under “Settings > Permalinks” section in your WordPress admin panel. This global setting decides the structure and the parameters to be included in the URL slug.
- Post title entered in Gutenberg or Classic Editor is then converted into a slug part of your URL by adding hyphens between each word of the title.
If you do not want to use the autogenerated slug with post title, you can also manually enter the description in the “URL Slug” text box in the editor screen. Note that the “URL Slug” box is available under “Permalink” meta box. You can only edit the last part of the URL (that is slug) and cannot change the URL structure (that is permalink).
Slug is generated during autosaving the content or when you click on of the “Save Draft / Publish / Update” options. Below is an example of how WordPress generates the slug:
- Permalink structure – https://www.mysite.com/sample-post/
- Post title – This is My First Post
- Slug – this-is-my-first-post
- URL – https://www.mysite.com/this-is-my-first-post/
Structure of Slug in WordPress
WordPress follows some rules in creating the slug.
- Slug is not case sensitive all letters in the title are converted to small case.
- Space between each word in the title is converted to a hyphen in slug. Any existing hyphens and multiple spaces are ignored.
- WordPress automatically ignores all special characters including “question mark (?)”, “exclamation (!)” and “is equal to (=)”.
Changing Slug in WordPress Gutenberg
You can change the slug by editing permalinks setup, title or slug description. As you can see in the permalinks settings page, WordPress will clearly show a warning on not to change the permalink structure in live site once setup. Changing permalink will affect the complete URL structure of your site and there are no possibilities in WordPress to have a custom permalink structure only for a specific post or page.
Therefore, you can edit the title or slug meta box to change the slug in the URL of your article. However, it works differently for a new and old post:
- For a new post – changing the title will automatically change the slug in the meta box.
- For an existing post – changing title will not have any impact on your slug, in this case, you can manually edit the slug. You can simply enter the descriptive words without worrying about the hyphens. WordPress will automatically add hyphens and ignore special characters as mentioned above.
When the length of post title is very long then slug can be modified to generate a short and meaningful URL. Below is an example of modified short slug which has lengthy post title:
- Post title – This is My First Post with Lengthy Post Title
- Autogenerated slug in WordPress – this-is-my-first-post-with-lengthy-post-title
- Manually edited short slug – this-is-my-first-post
- Final URL – https://www.mysite.com/this-is-my-first-post/
Sometimes, you will not see the “Permalink” meta box which has “URL Slug” editing option. In this case, click on the “Options” (three vertical dots” showing on top of the Gutenberg editor and select “Preferences” from the menu. Here you can enable the “Permalink” box under “Panels” tab.
Handling Slug in Classic Editor
If you are using old Classic Editor or using custom post types like WooCommerce products, then handling slug will be slightly different than as explained above with Gutenberg editor.
- First, you can change the post title to have a correct slug before publishing the post content.
- After saving or publishing the content, Classic Editor will show a shortlink below the title along with an “Edit” button. You can click on this edit button and modify the slug part of the URL.
- Click on “Screen Options” and select “Slug” option to view a meta box. In this slug box, you can edit the text to have different slug.
Note that, editing shortlink or changing the text in meta box will not change the post title. You have to change the title manually if required to have the same title and slug for your article.
Editing Slug in WordPress from Posts Page
Whether you are using Gutenberg or Classic Editor, the above method is easy to edit the slug within the editor. However, it will be hassle to open the editor when you want to change the slug for multiple articles. Fortunately, you have an alternate option to edit the slug from the Posts or Pages page.
- Go to “Posts > All Posts” or “Page > All Pages” menu.
- Find the post that you want to change the slug using search box and hover your mouse over the title.
- Now, you will additional options appearing and click on “Quick Edit” link.
- This will show options for editing the details of the selected post or page.
- Change your slug text in the “Slug” box and adjust the title if required.
- Click “Update” button to save your changes.
Note: There are SEO plugins in WordPress like Yoast SEO which also offers a slug text box to edit the text part of the URL. No matter, where you change the slug text, it will be changed in all the occurrences of that article.
Bulk Edit Slug in WordPress
The problem is that you can’t bulk edit slug in WordPress neither from the editor nor from the posts page. However, you can do this using a third-party plugin.
- Install and activate WP Sheet Editor plugin in your site. This plugin will allow you to edit all post details in an Excel spreadsheet within your admin dashboard.
- You can follow the instructions to use the free version of the plugin and go to “Posts > Sheets Editor” menu.
- You will see an Excel sheet opens showing slug and other details of all your posts.
- By default, slug field will be locked for editing showing with a padlock icon.
- Click on “Enable” link showing in the filed and open it for editing.
- Change the slug for multiple posts similar to editing content in Excel sheet and save your changes.
- You may see a warning that changes are permanent and can’t be reverted back. Confirm that pop-up and save the slug changes.
SEO Perspective of Using Optimized Slug
Slug is very important from SEO perspective since it is the post URL Google and other search engines showing in search results. Consider the following when using or editing slug in WordPress.
- It is a good idea to keep it descriptive with the desired length so that Google will not truncate in search results page.
- Keep the title and slug same if possible so that users can easily remember important pages in your site.
- Make sure to setup 301 redirect from old URL to new URL when changing the slug. Free plugins like Redirection and Rank Math can do this automatically for you while Yoast SEO needs premium version.
- It is also a good idea to remove all meaningless words from the slug without affecting SEO of the article. Words like “the”, “a”, etc. are stop words and not add value in search engine results. You can avoid using these stop words to adjust the slug length.