Cleaning up URLs

Why do some of my page links have extra numbers, likeĀ “mywebsite.com/about-2?”

The “-2” is caused by creating pages or posts with the same title. WordPress needs a unique name (called the “slug”) for every post, which it creates, by default, from the post’s title. If another post is created with the same title, WordPress will add an increasing number to the end of its slug to keep the posts distinct from each other in the database.

For example, working on your About page, you decide to make another version. When you title the second post “About”, the same as the first post, WordPress will quietly give it the slug of “about-2” (seen in the post editor as “Permalink”, just below the title).

Of course, you can use the Edit button to change the slug to whatever you want, including simply “about” (slugs are always lowercase and alphanumeric, with only underscores or hyphens as special characters).

It won’t let me change it to just “about”.

You have to get rid of the other post named “about” to let the newer post have that slug.

But I’ve already trashed the first version, and it still won’t let me change it.

You have to empty the trash to truly free up that slug. A post in the trash is still in the database (which is how we can restore it at another time if we so choose). Emptying the trash permanently removes that post from the database, and frees up the desired slug.

Clean URLS are an important part of effective SEO (search engine optimization) and make your links as simple and memorable as possible for your users. Clean ’em up!

Published by

Kirk Wight

I am a Code Wrangler at Automattic, helping make WordPress.com the best it can be. Pender Island, British Columbia, Canada is where I call home. Lover, not a fighter.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s