Shorten Your WordPress Slugs (Permalinks)

Share this!
Note: This article assumes you have configured your WordPress Permalink settings to include the post name. If your permalinks use the default setting, then (a) this tip doesn’t apply and (b) you really ought to change your permalink settings to include the post name!

When posting a blog article or page to your WordPress Web site, WordPress will automatically generate a "sanitized" slug which is the defining element of the post in its URL. Unless you manually edit that slug (which can be done in two ways, described below), the default slug will be the title of your post, with all letters changed to lowercase and all spaces and other special characters (commas, slashes, etc.) converted to hyphens or removed.

So, if your blog title is "Piano Lessons" and your Web site is "http://myblog.com", the URL to that page will look something like:
http://myblog.com/piano-lessons/

If your blog title is "Holiday Bazaar", the URL will look something like this:
http://myblog.com/holiday-bazaar/

Let’s suppose…

So, suppose you’re publishing a blog article about the lesson your learned about putting your online banking username and password on a sticky note attached to your computer monitor at work.

You might get creative and entitle your post, "Here’s something really, really stupid I did recently which I recommend you never do" Not a bad title, actually. If I saw title that in my newsreader (or Facebook newsfeed or Twitter timeline, etc.), I might be inclined to click and read.

So that’s the good news.

The bad news is that the URL for your post will be:

http://myblog.com/heres-something-really-really-stupid-i-did-recently-which-i-recommend-you-never-do/

Why is that bad?

  1. Broken Link Syndrome: That URL is so long that if you were to email it to a friend, there’s a chance your friend’s email program would break the link, preventing your friend from getting to the article.
  2. No key words: A Web page’s URL is one of it’s critical search engine optimization elements.

What’s a better URL?

How about…
http://myblog.com/keep-passwords-safe/
or even
http://myblog.com/avoid-sharing-online-banking-passwords/

You get the idea.

How to edit your slugs

Note: In each of the methods described below, the new slug you enter will be sanitized (letters lowercased, spaces replaced with hyphens, special characters removed) after you do the Update.

Method #1

Edit the slug right under the post title in the Edit Post page. Just click the Edit button and enter your new slug. (Click small images to enlarge.)

Method #2

If your screen options for Edit Post are set to display the slug section, find it somewhere on the screen and enter the new slug.

Method #3: Quick-Edit from the All Posts listing

Hover your mouse over the title of the post whose slug you want to change, and a little menu will appear under the title. Click on "Quick Edit" link.

This will expose a whole bunch of settings you can change without actually loading the Edit Post page. Type your new slug in the Slug box, and click Update. (Click image to enlarge.)

Voila!

Postscript: Changing Slugs Retroactively

You might be wondering…

Can I and should I go back and change some of my longer post slugs after the pages or posts have been published?

That’s a good question.

The answer is "probably yes". But here are a few things to consider before you change the slug of any post:

  • Losing people.
    If you emailed the original link to people, or posted it on Facebook — or anywhere else, for that matter — people who click on the original link will end up on your site’s Not Found page. This also applies if the original link of the page in question has been listed by search engines.
  • Losing some search engine mojo.
    If the original link of the page or post in question has already been indexed by search engines, it’s only a matter of time before those engines remove the link (which is, in a way, a good thing, since it’s a "bad" link). But until the search engines index the new link, you’ve lost a place in the search engine results. (Having people go to your Not Found page at least gets them to your Web site.)
  • Internal links.
    If you’ve manually linked to the page or post in question within the body of other pages or posts on your Web site, those internal hyperlinks will no longer be valid. (Small print: Unfortunately, WordPress’ native linking tool in the Edit screen hard-codes the URLs when you create hyperlinks. Some day, WordPress will probably fix that and use the IDs of posts in their linking tool, thus avoiding the broken link problem.)

HTH!

If you have questions or comments, please post them below.

Share this!

About JeffCohan.com

The nSiteful Tech Blog (the official blog of nSiteful Web Builders, Inc. since January of 2013) is where I (Jeff Cohan) and (occasionally) associates will be posting articles of potential interest to like-minded techies, nSiteful clients who are playing active roles in the maintenance of their own Web sites and blogs, and pretty much anyone interested in how Web strategies and tools can help them reach their goals.

This entry was posted in Techniques and tagged by Jeff Cohan. Bookmark the permalink.

About Jeff Cohan

Jeff and his wife, Margie, are the proud parents of Sarah and Jake. Jeff is the founder, president and chief cook and bottle washer of nSiteful Web Builders, Inc., a Web development and Internet Consulting firm. In his spare time, Jeff builds Web sites and Web applications, plays guitar, putters around in his basement woodworking shop, mercilessly spoils his grandchildren, and creates videos from more than two decades of home movies. His current video project is an extended montage of people (mainly family members) asking him to stop filming them.

9 thoughts on “Shorten Your WordPress Slugs (Permalinks)

  1. Hello Admin,

    Well done for this helpful article. Can you please suggest me the perfect slug of the title. I mean to say that what should be there in slug section ? Can we replace default slug by keywords ? Can we remove few words from default slug for this ?

    So, please help me !!!

    waiting for your suggestion Admin.

    • I like to keep slugs short. I like them to include keywords. I almost always edit the default slugs and remove unnecesary words. For this particular blog entry, for example, I removed the word “your”, which appears in the title but which isn’t needed in the slug (IMO).

  2. Very helpful Jeff, thank you. I try to make simple and easy to understand post so I am happy to see someone do a much better job.

    I hope to start adding screen shots too, it only get’s better.

  3. Had query about this slug shortening which has always been pointed up by my SEO analysis page. But got my query resolved after seeing your this post. Thank you so much!

Leave a Reply

Your email address will not be published. Required fields are marked *