Tänk dig att dela ett blogginlägg som heter ”10 tips för …” och att URL:en slutar med en string av meningslösa siffror. Den URL:en berättar inte för användare eller search engines om innehållet i artikeln.
Det är därför som Googles guide för sökmotorsoptimering uppmuntrar till användning av enkla, läsbara URL:er.
En del Beginnare väljer WordPress-inställningen att använda siffror i URL:er för att senare upptäcka att det är dåligt för sökmotorsoptimering. Vi får ofta frågan om hur man fixar det här på bästa sätt.
I den här artikeln visar vi hur du tar bort siffror från WordPress URL:er och använder permalänkar som är läsbara för människor istället.
Varför ska man ta bort siffror från URL:er i WordPress?
När det gäller att skapa URL:er för din WordPress website är det viktigt att de är sökmotorsoptimerande och hjälper till att förklara din artikel för besökarna.
Att lägga till siffror i en URL skadar inte din WordPress sökmotorsoptimering eller keyword ranking. Det gör det dock svårare för search engines att förstå posten. På samma sätt kan dina användare också ha svårt att hitta rätt content om det bara innehåller siffror.
Här är ett exempel på en sökmotorsoptimerande URL som inte har några siffror:
https://www.wpbeginner.com/sv/start-a-wordpress-blog/
Å andra sidan, så här skulle din URL se ut om den bara hade siffror, som ett ID:n för en post:
https://www.wpbeginner.com/sv/?p=11245
Som you ser är links med ett keyword eller en fras mycket lättare att förstå och lättare att hitta än numrerade URL:er.
En annan fördel med att ta bort siffror från URL:er är att du inte behöver redirecta ett blogginlägg när innehållet uppdateras. Det är till exempel en sökmotorsoptimering att ta bort siffror som år, dag eller det totala antalet objekt i ett listobjekt från URL:en.
Med detta sagt, låt oss se hur du tar bort siffror från en WordPress URL.
Video Tutorial
Om du föredrar skriftliga instruktioner är det bara att fortsätta läsa.
Remove av siffror från URL:er i permalänkar i WordPress
WordPress har built-in support för sökmotorsoptimering av URL:er.
Allt du behöver göra är att öppna Settings ” Permalinks page i WordPress admin area och välja en URL-struktur för din site admin.
Du kommer att se olika alternativ för dina permalänkar. Dessa inkluderar en vanlig struktur där din URL innehåller postens ID:n, en dag- och namnstruktur, en månad- och namnstruktur, en numerisk struktur och en postnamnstruktur.
Vi rekommenderar att du väljer strukturen ”Post name” som visar titeln på ditt post i URL:en eftersom den är sökmotorsoptimerande och hjälper andra att hitta din site i search engines.
När du har ställt in permalänkar behöver du bara save your changes.
WordPress kommer nu automatiskt att ändra URL:er för alla dina föregående inlägg också. Oroa dig inte om du har publicerat de äldre URL-adresserna någonstans eftersom WordPress automatiskt kommer att redirecta dessa användare till nya URL-adresser.
Ta bort siffror från en post eller page slug
Även om du använder permalänkar nu kanske du fortfarande vill bli av med siffror i URL:en till blogginlägget. Det vanligaste skälet till detta är när du publicerar ett post utan rubrik eller om rubriken innehåller ett nummer som gillar ett år.
Kom ihåg att WordPress väljer den text som ska visas i URL:en från ditt inläggs rubrik, så om ditt post inte har en rubrik eller innehåller ett årtal kommer WordPress att använda det i URL:en. Istället för numret på posten kan du manuellt tala om för WordPress vad som ska användas i URL:en.
Ta bort siffror från URL-sluggen i WordPress Block Editor
För att editera URL:en för något content på din site måste du editera ditt blogginlägg eller din page.
När du är i WordPress block editor kan du click på gear icon i det övre högra hörnet och öppna inställningar panelen.
Därefter rullar du bara ner till permalänkens section i panelen Settings och editar URL Slug. När du inte har en titel för ett blogginlägg visas ID:n för inlägget som standard.
I screenshoten ovan använder WordPress det aktuella post ID:n 45
som URL-slug.
You can edit that or simply enter a title for your blog post, and your URL slug will automatically change to your post title.
När du är klar, glöm inte att Publicera eller Update ditt blogginlägg.
Remove siffror från URL-sluggen i WordPress Classic Editor
Om du använder WordPress klassiska editor, då du också redigera din post permalänk och ta bort siffror.
Först lägger du till ett nytt blogginlägg eller redigerar en befintlig page.
När du är i den klassiska Editorn kommer du att se din posts URL med en ”Edit” knapp precis under postens titel.
Om du klickar på knappen ”Edit” blir URL:en redigerbar. Denna editerbara del anropas post slug. Du kan enter den text som du vill använda som post slug i URL:en och remove siffrorna.
Vad sägs om siffror i duplicerade poster och pages?
Ibland fortsätter -2
att addas till dina URL:er även när du editar den customiserade sluggen. Till exempel, du skapar en new About page och din URL ser ut så här:
https://yoursite.com/about-2/
Nu skulle du inte vilja bli av med den -2
, och helt enkelt ha /about/
? Detta problem uppstår när du har samma slug som redan används.
Kontrollera alla dina posts och pages för att se att ingen har samma slug, till exempel /about/
. Om du hittar en, måste du ta bort den om du inte använder den. Oftast kommer du inte att hitta en aktiv page med samma slug.
Det är då du behöver titta i mappen Trash. När du trashar ett WordPress post eller page, är det inte helt borttaget. Det ligger i trash i 30 dagar innan det blir permanently deleted. Detta görs för att ge dig alternativet att återställa trashade objekt om du av misstag har borttagit dem.
Sluggen kan inte återanvändas så länge posten eller page ligger kvar i trash. Så om du vill återanvända sluggen /about/
måste du delete About-sidan som ligger i mappen Trash.
När du har gjort det bör du kunna editera din slug, gillar metoden som visas ovan, och bli av med -2.
Den här tekniken fungerar även för kategorier och tags.
Bonus: Konfigurera 301 redirects när du ändrar URL:er
När du redigerar en URL-slug för befintligt content skapar WordPress en new page eller post. Detta kommer att leda till duplicerat content på din website med olika slugs.
Det vill du inte eftersom det är dåligt för sökmotorsoptimering i WordPress. Det beror på att search engines inte kommer att veta vilket content som ska rankas, och den befintliga länkens auktorisering kommer inte att överföras till den nyligen ändrade URL:en.
En enkel lösning är att ställa in redirect när du ändrar URL:en.
All in One SEO (AIOSEO) är det bästa SEO-tillägget för WordPress och har över 3 miljoner användare. Det erbjuder en kraftfull hantering av redirects som hjälper till att ställa in 301 redirects och fånga upp brutna links på din website.
Note: Hanteraren för redirect är tillgänglig i AIOSEO Pro-licensen. Det finns också en gratis version av AIOSEO som du kan använda för att komma igång.
Allt du behöver göra är att enter den slug som du vill redirecta (Source URL) och add the new changed URL (Target URL). Härifrån måste du välja ”301 Moved Permanently” som din Redirect Type.
Vänligen se vår guide till att skapa 301 redirects i WordPress för mer details.
Expertguider om URL:er i WordPress
Nu när du vet hur man tar bort siffror från URL:er i WordPress, kanske du gillar att se några andra guider relaterade till WordPress URL:er.
- Ordlista: URL
- Ordlista: Post Slug
- Vad är en URL för en website (viktiga delar förklarade för Beginnare)
- Så här skapar du customize-permalänkar i WordPress (Ultimat guide)
- Så här inkluderar du Category och Subcategory i WordPress URL:er
- Så här tar du bort datumet från WordPress URL:er
- Hur man tar bort v=XXXX String från WordPress URL:er
- Hur man ändrar författarens URL slug och bas i WordPress
- Hur man tar bort Parent Slug från Child Page URL i WordPress
- Hur man blir av med /wordpress/ från din WordPress Site URL
Vi hoppas att den här artikeln hjälpte dig att lära dig hur du tar bort siffror från WordPress URL:er. Du kanske också vill se vår guide om hur man startar en online store och vårt expertval av de bästa apparna för virtuella telefonnummer för småföretag.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
LorriAnne says
Looking at these screenshots and then looking at what I have in my WP, I believe someone’s pulling my leg with some really good photoshopped images. This tutorial is not valid.
WPBeginner Support says
Our guide is using the current block editor. If you do not see the same interface there are three likely culprits. If you are using a page builder plugin that would override the default editor with some, if you are using the classic editor plugin you would see the old classic editor interface, or if you are using WordPress.com then you would see their interface instead as our articles are for WordPress.org sites.
Administratör
Hussain Ali says
Can we edit our website’s domain name and keep the data safe?
WPBeginner Support says
Your site’s content would be safe when updating your domain for this tutorial.
Administratör
Thomas says
Hi,
Thank you for a very informative video / article.
I have the same issue that you talk about, where the ”-2” appears on one of my sites, however, I have nothing in my trash?
Currently, this issue arises on my local server and I would love to get it fixed before I take this live. Could you help me?
WPBeginner Support says
You would want to try to visit the URL without the -2 in it to see if it directs you to a page in which case you should be able to click the edit option in the admin bar at the top of your site.
Administratör
pankaj says
Awesome!
Thankyou!
WPBeginner Support says
You’re welcome
Administratör
Tamás says
Hello!
I like to get WP to start the numbering on repeating slugs from 8 digits.
E.g. sample-post, then sample-post-0000001
Any idea? I don’t find anything related and would be extremeley important.
Thx!
Best
Tamas
WPBeginner Support says
Sadly, at the moment we do not have a recommended method for setting that up.
Administratör
Ajay says
Dear Editor,
I have a question about how to remove tag from wordpress url?
old url: site.com/tag/movies
New Url : site.com/movies
How do I do that in wordpress? And how do I make the url direct from the old url?
WPBeginner Support says
For the URLs, you would want to take a look at our guide here: https://www.wpbeginner.com/wp-tutorials/how-to-create-custom-permalinks-in-wordpress/
After changing your URLs, you would want to create a redirect using one of the methods here:
https://www.wpbeginner.com/beginners-guide/beginners-guide-to-creating-redirects-in-wordpress/
Administratör
Bilal says
Today, when I working on Login page to place Password recover form short code, I Turn of Social media Login. After that I Logout Admin and checked that, two changes observed, one is Login form shwing very small size, second is all pages showing IDs when open in browser
Now what I do to set it, in settings, Permalinks seting are ok like previous, what thing changed, which showing IDs after url.
Any solution.
WPBeginner Support says
You would want to let the social media login plugin know what happened to the login form after disabling and they should be able to assist. If it is a ? followed by a number then you are likely using an ecommerce plugin that is tracking sessions so it can save the cart for the user.
Administratör
Bita Gh says
I have a problem in my wordpress website. my old website has been linked to my new website though an URL which I can not find. I want to delet or disable that link especially in google search. because that is linked to my old shop and old prices and people keep calling about the differences in prices. please help!
Janice Sullivan says
My links are ok but on the top bar I see ”All Posts | ”my link name”. ’All post’ is not part of the name of the page/blog posts or in the link? I can’t figure out how to remove it…any help out there?
Adrian McCarthy says
Thank you, thats such a simple solution and works brilliantly thank you.
Sarah X says
Hello. I did what all the steps you did but the 2 continues to show up in the url. I dont know what to do . i deleted and add like 3 times the same page and that number still there … :s
Whats wrong ? can you help me pls
Appreciate the attention
Sarah. from Portugal
WPBeginner Support says
Hi Sarah,
When you delete a post or page in WordPress, it goes into the trash. You need to delete that page from Trash as well. Go to Pages » All Pages and you will see a row of links to sort pages according to their status (Published, Draft, Scheduled, Trash). Click on the trash to view the pages that you have deleted earlier. Once you are there you will see a link ’Delete Permanently’ below each article clicking on it will delete the page permanently and you will be able to use that slug for your new page.
Administratör
Kat Zimmer says
Hi there,
I’ve combed through our site and taken all the actions you’ve suggested (permanently delete everything in the trash and ensure there is no photo/media file with that slug) and it’s STILL naming my slug with a -2 at the end. Please help!!
WPBeginner Support says
Hi Kat,
Please check your pages and categories as well. Also try visiting the full url to see if there is a post, page, or attachment with the same slug.
Peter says
How can I produce a list of permalinks that have ”-2” at their end, so I can correct them? I have 291 posts, 48 pages, and around 50 product pages.
In addition, I have two ecommerce stores, one for Australia (/shop/bookname) and one USA (/books/bookname), and all products have permalinks. Doesn’t permalinks take notice of the rest of the URL?
Thanks,
Peter
Sarah says
I deleted a post and when I went to make a new one the -2 is STILL there. Any other help?
Shaikh says
I didn’t have any pages still in trash. I didn’t have a category with the same name as my page. I didn’t have another page with the same name. So I did something crazy. WP was trying to name my page as page-2, so I went to mywebsite.com/page to see what happened.
A page with a single photo popped up. I had a PHOTO with the same name as the page, and WP media manager gives photos permalinks based on the file name! Fix was to rename the photo (still keeping SEO in mind), and using the permalink editor for the page. TAH DAH! Like magic, it worked
Chrissy says
Ah, I was pulling my hair out with this and what you’ve found out has solved my issue. Thanks for posting your findings, very helpful…
Janssen says
is there any way to also hide the url link? for example, mysite/mypost/ instead of 192.168.0.1:8080/mypost/
Christa says
I found your post because I do wonder about the following number behind all the pages and posts I have on my website which then looks like this: example.com/?v=b9610cde4c4c.
If I check the number only with google there comes my site with two pages and another very strange facebook website kind of….
I saw that someone commenting did find out about a plugin – so I deactivated all social plugins, I haven’t got hers on my site. The Permalinks are checked and correct and I didn’t find anything to change or this number, in my php. Do you have any Idea, what this could be or must I worry…?
WPBeginner Support says
If you are worried about security of your site, then you can try scanning your website with Sucuri. If the URLs are getting indexed in search, then it is not good for your website’s SEO.
Administratör
Christa says
Hello, thanks for your reply and yes, I will check it at sucuri – good idea! I don’t understand what you mean by ”if the URL’s are getting indedexed in search…” what do you mean by that?
Thank You!
Richard says
I Once Had The Problem Of Seeing the -2 slug being shown for duplicate pages left in trash. However with a New Site I was Editing I was Still Having the -2 show up in title but there was not anything in my Trash For Pages. I Finally Searched My domain with the correct title I wanted and Up Popped one Of the images in my IMAGE Library that had the same name of the page I kept trying to correct. So Images with Names the same as your titles will cause this Behavior too. Just My Experience with the problem.
WPBeginner Support says
Images are also stored as attachment which is a built in WordPress post type. Like all other post types attachments also have slugs. So yes if you have an attachment with slug my-first-bike and then you try to add an article with the same slug, then WordPress will add a number to the slug.
Administratör
trey says
Had the same problem on a page. Deactivated all plugins, quick edit of page url. and bingo it now works, tried everything to no avail before!
Paul Sadler says
Unfortunately, this article is a bit simplistic as that is not always what causes the -2 to be added. While it will do it if there is already an ”about” and you are adding another page or post called ”about”, but it also has problems with numbers as the titles of pages.
I am creating a gallery and some of the layout is a bit manual for organization, partly as I am wrapping text around the intro and conclusion. So I called one of the pages 2015, another 2010, another 2016. Doesn’t matter what I call it, there is nothing in my trash by that name, it is entirely ”new”, but WP will NOT allow it. Why? Because it knows it looks like a year and it doesn’t like numbers only in the structure.
So I can’t have ”2015 / January” as my structure, it will have to have some other letter in there for the year plus of course I can’t have the ”January” page every year, leaving me with a URL that will look like Y2015 / 2015-January…not very elegant I’m afraid, but seems to be the only solution other than running a custom plugin that overwrites the slugs and risks breaking all of the WP install.
Paul
Chirag Gupta says
how can i remove category or tag from url…
example.com/category/mobile >>> example.com/mobile
WPBeginner Support says
See our guide how to change category base prefix in WordPress.
Administratör
andrew says
I seem to no longer be able to add a permalink with just four digits (ie ”http://example.com/1223”)
You used to be allowed to do this for posts but not pages, now you can’t do it at all and it is really messing up one of my clients sites.
Devang Sharma says
Thank You very much guyz ! You don’t know how disturb i was…..
Damaris says
How do you change it if you have wordpress beginner?
WPBeginner Staff says
This is unusual behavior. Please deactivate all your WordPress plugins and switch to a default theme like twenty thirteen or twenty fourteen. See if your posts still have links like this. If they do then it is likely that your WordPress security is compromised.
Karon Warren says
I have permalinks set up on my site with ”post name” as the default setting. And that does work. However, when you actually click on the live post, it initially comes up with the permalink, but after fully loading, it has a series of numbers/letters attached to the permalink, like this: #.VB2dTCtdVW0
How do I get rid of those numbers from the actual permalink?
Janet Bauske says
Karon, I had the same problem. I found the culprit was the AddThis social bookmarking widget. To remove it, go to the Plugin settings under Settings > AddThis Share > Advanced Tab and turn off the Address Bar Shares Tracking.
Cathy Sirvatka says
I have been trying to figure out the number thing for a long time. Thank you for this!! I had no idea files in the trash were still using the page name!
Steve says
I have the same problem (-2 at the end). I have cleared my trash, etc but I’m still having the same problem. I have an about-2 page, but no sign of an about page. Any ideas?
Rugby says
Really helpful – had problem with -2 being added to my posts page and emptied trash and hey presto gone! Thanks
Theresa says
sometimes the littlest things can feel like a stalemate. thanks for providing all these great tips
Michael Monday says
Splendid !!! You just said it all !!! Thanks a lot for this long-sought solution to the ”urgly” url I have had to deal with for months. Now my posts url looks good. Thanks a lot My Balkhi and your team
John says
This is all great information! I would like to know if I can use some of what I find here to post on my site, or include in email campaigns. Specifically, referring to the badge in this post for removing numbers from urls in WP, but also would like to know if there are others available, within the confines of best practices of course.
thanks,
jag
Keith Davis says
Hi Guys
I’ve got pretty permalinks set so I’ve had no problems with that but I have had the 2 appear in a couple of posts.
The first time I trashed a post and started again not realising that trashing is not enough: you have to delete it.
The second time I trashed and deleted the post but still got the dreaded 2 at the end.
No idea why that would happen.
Gretchen Louise says
Is the automatic redirection of permalink styles a new feature? I still use custom .htaccess code but have had issues with it eliminating my date-based archives, too.
patty jones says
WordPress automatically redirects to the new permalinks? I have wanted to change the permalink structure of my site for a long time but worried how it would affect links that are already out there.
Our site has over 4000 posts and I figured it would kill our page rank. What are you thoughts on that many redirects?
jayism says
This is an interesting post, but it does not cover how to remove the site.com/category-2/sub-category/heres-a-post.php – I have this problem, and read it happens when you create a category called software, then delete it, and create it again further down the track – the original ’software’ remains in the DB for ’categories’ – therefore it is forced to name the category with a -2 so the Database doesn’t have a duplicate….
The only ways I’ve read to fix this in numerous posts is going into myPHPAdmin and deleting the original ’software’ manually! Your post has shed some light on the situation, and may have another way to get rid of the -2 fro actual categories?
Thanks,
@jaycameron of ’Crowd-Sourced Development Initiative’ -> @Code_Collective
Karen says
How excellent! That hint about the trash is a gem. And go ahead and laugh – but – I knew what pretty permalinks were – but was confused if that was what acheived with clicking the Post Name option. I’d been confused because I used to do my Pretty Permalinks using the custom option – until this new button was added. So thanks for solving that tiny mystery for me!