You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We seem to have lost the ability to use custom taxonomy routes.
I have a taxonomy named Magazine Topic. It seems to also suffer from issue #2273.
On Statamic v2 we had defined a custom route for the taxonomy to use /magazine/topic/{slug}. I don't seem to be able to reproduce it on Statamic v3.
Statamic version: 3.0.7
PHP version: 7.3
Reacted by Mike Martin, Iosif Chatzimichail, Jon, Matthew Fitzsimmons, John Carter, Frank Peters, Jonas Siewertsen, Andrew Haine, Michael Aerni, Loris Leiva and 18 more
Hey @warkior
I agree that there should be a way to customize the taxonomy routes but have you tried naming your taxonomy topic and adding that taxonomy to your magazine collection settings? Then the taxonomy url /magazine/topic/{slug} should resolve.
+1 for this. Working with taxonomy routes and having them Just Work™ is a little harder in v3. It would be nice to be able to define a custom route and still have access to the data, like on the default routes, available there too.
+1 for this as well. We also heavily relied on custom routing functionality. And we do not use a similar structure as @warkior as we use taxonomies both as content as well as filtering for blog items for instance.
I'm going to check if we can use this workaround, but I am afraid it will not be compatible.
I have come to the conclusion that we cannot implement the workaround as suggested. So we are now forced to migrate the taxonomy to a collection instead, as it allows us to use a custom routing scheme.
@FrankPeters You can still define custom routes in your routes.php file. You can then use {taxonomy_term} in your templates to get the term. It's just a bit more limited than the automatic routes that Statamic provides.
@JonKaric Thanks! It seems to have worked. This will save a ton of work. Still have to solve some issues, but they appear minor now compared to converting to collections ;-)
@FrankPeters Oops, pretty sure it wasn't intentionally left off the list of breaking changes. Thanks for pointing that out though. I've PR'd it into the docs statamic/docs#319.
This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.
Using the example from the docs, on /blog/tags/retrowave all the 'retrowave' entries would be listed. But the url to each entry would be something like /blog/retrowave/entry-post-url-here.
Based on the need for the taxonomy slug to be present in the URL for the collection term page, I would expect it to be used in the entry url - but it's not?
But the url to each entry would be something like /blog/retrowave/entry-post-url-here.
Where are you getting that from? The URL of the entry is defined in the route in the collection. If it's route: 'blog/{slug} then the url would be /blog/entry-post-url-here. The entry urls aren't affected by taxonomies.
Apologies, I had the wrong end of the stick! I get taxonomy URL and collection URL are two different things.
Are there (any near future) plans to bring back custom taxonomy routes as mentioned at the top of this post? Or fixing the issue @1stevengrant mentions? Seems like the docs say custom taxonomy routes are possible, but it's not working?
Currently I need to use this structure when using a taxonomy with a collection collection-name/taxonomy/term, it'd be nice to be able to use collection-name/term instead.
I think in most cases I could live with the default structure collection-name/taxonomy/term, but for a particular website I'm working on I need three taxonomies.
Group /solutions/group/term
Categories /solutions/categories/term
Sub Categories /solutions/sub-categories/term
It'd be neat if I didn't need to expose the taxonomy name in the URL
The custom route options for collections work really well, could something similar be applied to taxonomy routes in a future release?
This allows page loads of /magazine/topics/something to load the something term, show a custom 404 if it's missing, and show the view with all term data if it exists. For clarity our term handle is actually magazine_topic.
We are then able to use the following in views/magazine_topic/show.antlers.html.
I have the strange case where on my development and staging environments the collection-name/taxonomy/term path works fine with the custom templating, but on the production environment same path returns 404 page.
The content, views etc between all environments are synced (merged branches).
Closing in favor of statamic/ideas#839. We're right on the fence between deprecating Taxonomies entirely and going all in on Collections, or doing the big work. We'll see. But this is an old issue and I'm trying to clean everything up. 😅
Activity
mikemartin commentedon Sep 15, 2020
Hey @warkior
I agree that there should be a way to customize the taxonomy routes but have you tried naming your taxonomy
topicand adding that taxonomy to your magazine collection settings? Then the taxonomy url/magazine/topic/{slug}should resolve.JonKaric commentedon Nov 15, 2020
+1 for this. Working with taxonomy routes and having them Just Work™ is a little harder in v3. It would be nice to be able to define a custom route and still have access to the data, like on the default routes, available there too.
FrankPeters commentedon Nov 25, 2020
+1 for this as well. We also heavily relied on custom routing functionality. And we do not use a similar structure as @warkior as we use taxonomies both as content as well as filtering for blog items for instance.
I'm going to check if we can use this workaround, but I am afraid it will not be compatible.
FrankPeters commentedon Nov 26, 2020
I have come to the conclusion that we cannot implement the workaround as suggested. So we are now forced to migrate the taxonomy to a collection instead, as it allows us to use a custom routing scheme.
This is really disappointing as this breaking change is not even documented on the https://statamic.dev/upgrade-guide#breaking-changes-core page.
JonKaric commentedon Nov 26, 2020
@FrankPeters You can still define custom routes in your
routes.phpfile. You can then use{taxonomy_term}in your templates to get the term. It's just a bit more limited than the automatic routes that Statamic provides.I do wish it was possible to 'attach' a taxonomy to a route like the one above, though.
FrankPeters commentedon Nov 26, 2020
@JonKaric Thanks! It seems to have worked. This will save a ton of work. Still have to solve some issues, but they appear minor now compared to converting to collections ;-)
duncanmcclean commentedon Nov 26, 2020
@FrankPeters Oops, pretty sure it wasn't intentionally left off the list of breaking changes. Thanks for pointing that out though. I've PR'd it into the docs statamic/docs#319.
github-actions commentedon Jan 26, 2021
This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.
JonKaric commentedon Feb 2, 2021
Re-opening this
6 remaining items
jasonvarga commentedon Apr 14, 2021
Just pointing that out since some comments sound like they didn't know that was possible.
1stevengrant commentedon Apr 14, 2021
sure - I've not had any issues on new builds but definitely a quirk on a migration
stephenmeehanuk commentedon Apr 14, 2021
I guess I was wondering if it's possible to drop the taxonomy name from the URL?
When viewing
/blog/tags/mytagcould/blog/mytagbe used instead?jasonvarga commentedon Apr 14, 2021
@stephenmeehanuk where are your blog posts located? /blog/{slug}? wouldn't that conflict with /blog/{tag}?
stephenmeehanuk commentedon Apr 14, 2021
@jasonvarga I guess there would be a conflict...
I'm curious how this bit works though.
Using the example from the docs, on
/blog/tags/retrowaveall the 'retrowave' entries would be listed. But theurlto each entry would be something like/blog/retrowave/entry-post-url-here.Based on the need for the taxonomy slug to be present in the URL for the collection term page, I would expect it to be used in the entry url - but it's not?
jasonvarga commentedon Apr 14, 2021
Where are you getting that from? The URL of the entry is defined in the
routein the collection. If it'sroute: 'blog/{slug}then the url would be/blog/entry-post-url-here. The entry urls aren't affected by taxonomies.stephenmeehanuk commentedon Apr 16, 2021
Apologies, I had the wrong end of the stick! I get taxonomy URL and collection URL are two different things.
Are there (any near future) plans to bring back custom taxonomy routes as mentioned at the top of this post? Or fixing the issue @1stevengrant mentions? Seems like the docs say custom taxonomy routes are possible, but it's not working?
Currently I need to use this structure when using a taxonomy with a collection
collection-name/taxonomy/term, it'd be nice to be able to usecollection-name/terminstead.I think in most cases I could live with the default structure
collection-name/taxonomy/term, but for a particular website I'm working on I need three taxonomies./solutions/group/term/solutions/categories/term/solutions/sub-categories/termIt'd be neat if I didn't need to expose the taxonomy name in the URL
The custom route options for collections work really well, could something similar be applied to taxonomy routes in a future release?
jasonvarga commentedon Apr 16, 2021
I'd like to support it at some point since people clearly want it. I don't have an ETA though.
I've fixed Steven's issue with the docs by removing it. 😄
1stevengrant commentedon Apr 16, 2021
😂
1stevengrant commentedon Apr 16, 2021
@stephenmeehanuk here's how I've worked around it
jasonvarga commentedon Jan 28, 2022
Here's a gist with an example of how to implement custom taxonomy routes. It builds on what Steven posted.
https://gist.github.com/jasonvarga/4342f96b77d52fcd27dad22d88253e1f
warkior commentedon Feb 6, 2023
The various comments above have been very helpful. Here's a way we've solved it for now. We've added the following to our
routes/web.phpThis allows page loads of
/magazine/topics/somethingto load thesomethingterm, show a custom 404 if it's missing, and show the view with all term data if it exists. For clarity our term handle is actuallymagazine_topic.We are then able to use the following in
views/magazine_topic/show.antlers.html.{{ collection from="magazine_articles" taxonomy:magazine_topic="{slug}" paginate="true" as="posts" }} ... {{ posts }} <h3> {{ title }} </h3> ... {{ /posts }} ... {{ /collection }}Hope this is helpful to someone out there. :)
iipavlov commentedon Nov 6, 2023
I have the strange case where on my development and staging environments the
collection-name/taxonomy/termpath works fine with the custom templating, but on the production environment same path returns 404 page.The content, views etc between all environments are synced (merged branches).
Where should I look for the issue?
jackmcdade commentedon Feb 15, 2026
Closing in favor of statamic/ideas#839. We're right on the fence between deprecating Taxonomies entirely and going all in on Collections, or doing the big work. We'll see. But this is an old issue and I'm trying to clean everything up. 😅