What Is A WordPress Slug: A Slug or Post Slug in WordPress is that part of URL that is unique for every page in your website. Every single page on a website, except the home page, has a slug. Slug, as explained in this article on SEO-friendly URL structure, plays a very important role in optimizing the page for search engines. It can also be defined as the user-friendly as well as URL-friendly name of the page that identifies and tells both users and search engines what the page is about.
Sometimes, a URL can have more than one slug, separated by “/”.
Basically, Slug = URL – Domain Name, when custom permalink is enabled on WordPress.
How To Set Slug On WordPress?
In WordPress, slugs are automatically generated when you are writing a new post. But if the permalink structure doesn’t support slug, the URL will not use the automatically generated slug.
Go to Settings >> Permalinks and then select “%postname%”. Click on “Save Changes”. After that, every time you publish a post, it will bear the slug as generated by WordPress from the title of the post.
How To Edit The WordPress Slug?
Sometimes, you might feel the necessity to edit the slug that is automatically generated by WordPress, for example, if it is too long.
In order to edit it, do the following:
- Click on the “edit” option beside the automatically generated permalink, under the Title box on post editor.
- Make the necessary changes.
- Click on “Ok”.
What To Include In The WordPress Slug?
A slug can have the following:
- Letters, small letters to be precise,
- Hyphens instead of space between words
SEO practices demands short URL. This means you should keep the slug as short as possible. Remove unnecessary words from the slug, like preposition, conjunction, articles, which are called stop words.
Should You Edit The Slug After Publishing The Post?
Editing and changing the slug long after you have published the post is not at all recommended. This is because of the following reasons:
- Changing the slug after the page is published will result in same content in multiple pages.
- If you have linked your Page A from some other pages, changing the slug for Page A will result in broken link. Clicking on the link will take people to a 404 page.
- If people have saved Page A to visit later, they will land on a 404 page if they click on it after you have changed the slug.
- You will end up wasting link juice or link equity.
Although WordPress tries to redirect visitors to the new slug if it is a post or a page, sometimes this may not work. And for tags and categories, WordPress doesn’t redirect.
It is, therefore, advisable not to change the slug once a page is published and indexed. If you need to change it, make sure you setup a 301 redirect so that the link is not broken and visitors do not see a “Page Doesn’t Exist “. As per Google, using 301 redirect will help in retaining the link equity. But many SEO experts are doubtful about it.
I hope I have been able to explain everything you need to know about what is a WordPress Slug. If you have any question pertaining to what is a WordPress Slug, drop them below and I will get back to you.