Molte guide SEO di WordPress dicono che i permalink semplici sono i migliori. Ma dopo aver lavorato in corso d’opera con molti siti web, abbiamo scoperto che non è sempre vero.
A volte, soprattutto per i siti di grandi dimensioni, è meglio avere URL che mostrino dove ci si trova, come “yourstore.com/electronics/smartphones/iphone”. Questa struttura cancellata può rendere il sito più facile da usare.
Se siete nuovi di WordPress, vi starete chiedendo come impostare questo tipo di struttura di permalink per il vostro sito. In questa guida vi mostreremo come aggiungere categorie e sottocategorie ai vostri URL. Verranno illustrate le ragioni per cui è necessario farlo, come farlo in modo sicuro e a cosa prestare attenzione.
Quando includere la categoria e la sottocategoria negli URL di WordPress
Alcuni siti web WordPress utilizzano categorie e sottocategorie nei loro URL quando hanno molti contenuti sul loro sito e vogliono organizzarli meglio. Noi di WPBeginner utilizziamo questa strategia per rendere il nostro sito più facile da navigare per i nostri lettori.
Ad esempio:
https://www.wpbeginner.com/plugins/7-best-wordpress-backup-plugins-compared-pros-and-cons/
Per i negozi online, l’inclusione di categorie e sottocategorie negli URL fornisce un’indicazione visiva del contenuto a cui i clienti stanno per accedere, migliorando l’esperienza dell’utente.
Ad esempio, un URL come onlinestore.com/books/fiction/thriller indica che l’utente sta navigando verso una sottocategoria specifica all’interno di una categoria più ampia del sito WordPress.
L’inclusione di categorie e sottocategorie negli URL può anche aiutare i motori di ricerca a comprendere la struttura del sito. L’URL corrisponderebbe alla navigazione breadcrumb del sito e includerebbe più parole chiave e testo, rendendo il sito più SEO-friendly.
Per ulteriori informazioni sulle categorie, potete leggere le nostre guide sulle tassonomie di WordPress e sulle categorie rispetto ai tag: le migliori pratiche SEO per ordinare i contenuti.
Se si utilizza la struttura predefinita degli URL di WordPress, le categorie e le sottocategorie non sono incluse negli URL dei post. Vediamo quindi come aggiungere facilmente categorie e sottocategorie negli URL di WordPress.
Come aggiungere facilmente categoria e sottocategoria negli URL dei post di WordPress
Nota: si sconsiglia di modificare i permalink quando il sito WordPress è attivo da tempo (cioè da più di sei mesi). In caso contrario, potreste perdere il vostro posizionamento sui motori di ricerca.
Se dovete cambiare la struttura dei permalink, vi suggeriamo di fare un backup del vostro sito web in caso di errori e di creare dei reindirizzamenti dai vecchi URL a quelli nuovi.
Per prima cosa, è necessario visitare la pagina Impostazioni ” Permalinks nella dashboard di amministrazione di WordPress. A questo punto, è necessario fare clic sull’opzione “Struttura personalizzata” nell’area delle impostazioni comuni.
Successivamente, è necessario aggiungere /%category%/%postname%/
nel campo accanto a Custom Structure.
Dopo di che, non dimenticate di fare clic sul pulsante “Salva modifiche” per memorizzare le impostazioni della struttura dei permalink personalizzata.
Tutto qui!
WordPress inizierà ora ad aggiungere categorie e figli/bambini negli URL di WordPress. Potete vedere le impostazioni personalizzate dei permalink in azione creando un nuovo post o modificandone uno esistente.
È sufficiente assegnare al post una categoria (e una sottocategoria, se le utilizzate) nella barra laterale e fare clic sul pulsante “Aggiorna”.
Si noterà che il nome della categoria e della sottocategoria è incluso nel permalink del post.
Che aspetto avrebbe l’URL se si utilizzano più categorie o sottocategorie?
Immaginiamo di ordinare i post del blog WordPress in più categorie o sottocategorie.
WordPress includerà nell’URL solo una categoria e una categoria figlia. Se non si è scelta una sottocategoria, verrà mostrata solo una categoria madre.
WordPress sceglie la categoria in ordine alfabetico. Ad esempio, se si archivia un post utilizzando le categorie “Apple” e “Tecnologia”, WordPress includerà “apple” nell’URL perché è la prima in ordine alfabetico:
http://example.com/apple/article-title-here/
Se si archivia un post in “Apple” e una sottocategoria chiamata “Tecnologia”, l’URL includerà entrambe:
https://example.com/apple/technology/article-title-here/
Se si è selezionata una sottocategoria ma non si è selezionata specificamente una categoria genitrice, WordPress includerà comunque la categoria genitrice nell’URL.
Un altro scenario è quello in cui si ha una categoria madre, una sottocategoria e una sottocategoria. WordPress le includerà tutte e tre nel permalink di WordPress:
https://example.com/apple/technology/events/article-title-here/
Per ulteriori informazioni sui permalink, potete consultare le seguenti guide di WordPress:
- Come rimuovere i numeri dagli URL di WordPress
- Come rimuovere la data dagli URL di WordPress
- Come modificare i permalink dei tipi di post personalizzati in WordPress
Speriamo che questo articolo vi abbia aiutato a capire come includere una categoria e una sottocategoria negli URL di WordPress. Si consiglia di consultare anche il nostro articolo su come modificare il prefisso di base della categoria in WordPress e la nostra guida per principianti alla creazione di tassonomie personalizzate in WordPress.
Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.
Syed Balkhi
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!
AB Juma
Hi there,
Thank you for this. Very helpful.
Just a question – I already have more than 2,000 posts on my website with the day and name url structure. If I change to custom, will those urls change too, or does the change only apply to new posts? Thanks.
WPBeginner Support
Yes, if you change your permalinks it would affect everything on your site. You would want to set up 301 redirects to prevent issues if you change the structure, our guide below should help with that!
https://www.wpbeginner.com/beginners-guide/beginners-guide-to-creating-redirects-in-wordpress/
Admin
Jay
it’s only putting the Parent cateogry in the slug.
How can i make it automatically put subcategory in the url as well?
WPBeginner Support
Please check that the post is only in the subcategory for the most likely reason for that issue.
Admin
Brendon
This seems to break any products that do not use a sub category at all.
WPBeginner Support
It should not cause you trouble with products that don’t have a sub category but if you mean you changed your permalinks then you would want to set up 301 redirects following our guide below:
https://www.wpbeginner.com/wp-tutorials/how-to-create-custom-permalinks-in-wordpress/#redirect-permalink
Admin
Taoheed
I would be glad if you answer this. Let’s assume i published a post into two/three categories or sub-categories, wouldn’t it be treated as duplicate content on google?
WPBeginner Support
It should not cause Google to see it as duplicate content but if you have posts that are in multiple categories then your users would see that same post when they viewed your other categories. We would normally recommend only one category for a post.
Admin
David
Please is there a way to include tags in the URL instead of categories?
WPBeginner Support
We do not have a recommended method for including tags in your URL at the moment, we would recommend taking a look at our article below that covers the organizational differences between the two for why categories are preferred over tags in permalinks:
wpbeginner.com/beginners-guide/categories-vs-tags-seo-best-practices-which-one-is-better/
Admin
Phu Nguyen
Hi,
Currently I have a url: abc.com/games/ff9/weapon-list/
and I can’t create another post with the same name (weapon-list) on another category.
It will be like abc.com/games/ffx/weapon-list-1/
Is there any solution for my case? Looking forward to your help
WPBeginner Support
The end of the URL would be determined by your post’s name and the other sections would be determined by your permalink structure. You cannot have the same name for the time being and would need a different name
Admin
Lori S.
So for pages, it would just skip over the /%category%/ and maintain the original post name?
WPBeginner Support
Yes
Admin
Ashish
Is it a disadvantage to using categories in URL? like example.com/plugin/best-plugin/. in this case plugin uses 2 times. is this URL looks spammy?
WPBeginner Support
You would want to try avoiding looking spammy with your choice of title but it is not a disadvantage to use categories n your URL.
Admin
jacques
Important note: To get URL structure like: /category/child1/child2/POSTNAME then ONLY select “child2” as the post category when editing the post. Wordpress will automatically add all parent categories to the URL. Took me a while to figure that out.
WPBeginner Support
Thanks for sharing this for people looking for that permalink setup
Admin
Austin Epple
You’re the man. I’ve been tearing my hair out trying to get these stupid subcategories in the url. Thank you!
Smart
Thank you so much @jacques, you just helped me solve a challenge that has taking me so many hours without solution. Thanks mahn
Rubb
How this work with pages? pages don’t use categories
WPBeginner Support
As they do not have categories, they would not have the category in the URL
Admin
Ben
So how do i redirect from /%postname%/ to /%category%/%postname without the redirection plugin.
WPBeginner Support
For different methods to create redirects we would recommend taking a look at our guide below:
https://www.wpbeginner.com/beginners-guide/beginners-guide-to-creating-redirects-in-wordpress/
Admin
May
Is there a way to add hierarchy to parent categories? If a post has two categories how can I chose which category is used in the URL.
As you say in your article, default is alphabetical.
For example I have a post categorised “Fruit” and “Vegetable” with the permalink set to show /%category%/%postname%/.
The URL shows website.com/Fruit/postname but I want it to use website.com/vegetable/postname.
WPBeginner Support
In those situations, you may want to look into how your categories are organized to see if tags may be what you need more than categories for some organizations. Normally posts shouldn’t be in multiple categories.
Admin
Nik
How can I add category in my page url.
WPBeginner Support
By default, pages don’t have categories so they wouldn’t be included in the page options.
Admin
Mlimasolucoes
Use subcategory as primary category then URL will work
WPBeginner Support
Thank you for sharing that recommendation
Admin
Muhammad Kashif Rasheed
You answer is valuable for me, because I read all the post but not permalink not work fine on my side, when I applied your suggestion I got answer of my question.
Once again thankyou very much,
Sravankumar
I am unable to see subcategory in any posts.
I am facing issue while creating a post name. How can Icreate a URL like this: site/destinations/europe/norway/post-name
I have the page to create a URL like above is it only possible if I create a page or with post name also can we create?
site/destinations/europe/norway/
WPBeginner Support
If I’m understanding the question correctly, you don’t need to create a page at the second link’s location as that would be your subcategory’s page listing the posts in that subcategory.
Admin
Nancy
Can i Include Category and Subcategory in post URLs without using permalink
WPBeginner Support
If you don’t want to edit your permalinks then you would normally need to manually add those using a method in: https://www.wpbeginner.com/wp-tutorials/how-to-create-custom-permalinks-in-wordpress/
Admin
V
Adding /%category%/%postname%/ to the permalink structure breaks the pagination for some reason. Anyone else facing this?
WPBeginner Support
There are multiple possible reasons pagination could not be working, you may want to check with your specific theme’s support or reach out to us using our contact form for which would likely fix the issue.
Admin
jesica
How did you do to link your subcategory menu pages to a clean url: YOURSITE.COM/SUBCATEGORY? without the YOURSITE.COM/CATEGORY/SUBCATEGORY?
I don’t know how to delete the parent category from the subcategory URL on my site…
WPBeginner Support
We don’t have a simple recommended method at the moment. If you want to remove reference to the parent category, should that category be a child category?
Admin
Shubham Dixit
I have an issue. I am using Custom Structure to display category name before the post name ( /%category%/%postname%/ ). It is working fine when I am logged in but after log out It doesn’t display category name in url.
The above issue in in chorme browser. In firefox it is working fine.
Please help!
Ted
Yeah.. we all know this information.. you see %category% and it is obvious what it does. But Thanks….
WHAT I WAS LOOKING FOR is code as in rewrite rules for my themes functions file..
jcdarocha
Hi !
Trick works well for a blog post / category.
but what about woocommerce ? ay idea ?
Even when you add this in permalink structure, WC show the main-category/product-name even if there 2 or 3 sub categories
This is really annoying,
Any idea?
Thank you
Jean-Charles
Paul
Got the same question. Why is that not possible for Woocommerce?!
Any help is appreciated!
Simon
This is great, but how would I go about having multiple URLs for the same post with multiple categories? So if I go from 1 category the URL is for that category and if I go from another it is that category?
Thanks
Jordan
Won’t this cause duplication problems? How do you make it so the parent category doesn’t open to an archive page?
Like as an example – Main topic Music and then have a subcategory called popmusic…..
Music ( Not Clickable )
Pop Music ( Clickable and rediects to your posts associated with that sub categories)
My issue with this is people clicking the parent categories and getting redirected to a page with no post associated with it because you don’t want to have duplicate content or a post in music & pop music
Yash chandra verma
So what will be url if two different parent category are used. Please tell me?
Vale
Why Woocommerce do not support Subcaregories in permalinks?
Google and other browsers recommed clean URL’s. And woocommerce Category slug can not be removed unless you pay $119 Usd for a plugin that does the trick.
Is there another way to achieve these two issues?
Jose
Thanks for this post. Its working for me. The only thing doesn`t work is when i try to list news by a subcategory
Eg. mydomain.com/categorybase/subcategory/nameofnew/
this works showing me the blog post, but if i want to list all posts of this subcategory like this
mydomain.com/categorybase/subcategory/
does’nt work.
Any ideas how to fix it?
Thanks in advance.
Denish Callos
HI,
I have added categories and tags in my pages. Now how do i add categories in pages permalink?
Please suggestion will be highly appreciated.
Thanks
Kahil
This solution ONLY works if you select the subcategory in the post/page category list. If you have both the parent and the subcategories checked, then the parent category is the only one that shows. For those of us using Woocommerce, this messes with the related products. If you select just the subcategory, then you won’t see any related items from the parent category. If you select them both, then you’re back to dealing with not having the subcategory listed in your URL. Been looking for a simple solution to cover both needs.
Paul
Have you found a solution? We have the same exact problem right now. This is quite annoying and we don’t know what to do about it.
Any ideas or solutions are appreciated!
regel
Hi don’t have “permalink” on my setting. Any option?
WPBeginner Support
Hi Regel,
Your website is probably on WordPress.com. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
Admin
Giulia Sampogna
Hello,
that´s a really nice post. I am wondering if I change it now will change my past one as well? If yes I would had to redirect all links right?
Thanks a lot
Dan
I’m confused and could use some help.
Specifically, I am developing an ecommerce site that is composed of mostly PAGES. (NOT using woocommerce or another e-commerce platform, but building out my own gravity form for each product page).
I want the product category to be in ALL my PAGE URL’s, but as you know, wordpress out of the box doesn’t enable assignment of categories and tags to PAGES (wish it did). One alternative would be to use one of the plugins I found that could enable this. The other is to simply use the product category name in the SLUG (part of the permalink I can create on the product page). I could also create a page for each product category and include a gallery showing each product item that belongs to that category with a link to its specific page, or, I could skip the product category page altogether and assign the “#” in front of the category name when I create the menu, so that the category name would appear but not be an active link to any category page. I could get involved in creating a “custom post type” for my product pages which would enable them to be assigned a category and tag, much like the woocommerce product “pages” are setup (don’t know much about how to do that but would like to), etc.
Also, the permalink settings effect URL’s for both pages and posts…correct ?
REALLY appreciate a followup post from you that deep dives into helping people like me who are using wordpress for their ecommerce site but not using one of the out of the box ecommerce platforms.
thankyou