Skip to content

Taxonomy URL uses collection handle, not collection slug #11421

Description

@MariosIgkiempor

Bug description

I have a collection Trainer-Led Learning which is configured to use the route /trainer-led-learning/{slug}.

I have a taxonomy Staff Groups which is linked to the collection.

When using the {{ taxonomy }} tag, the {{ url }} that is produced links to /trainer_led_learning/staff-group/{slug}.

I'm not sure if it is intentional that the - in the collection slug is replaced by _. I assume the taxonomy is using the collection handle to generate urls, and does not respect its configured route? Interesting it doesn't use the taxonomy handle too ie /trainer_led_learning/staff_groups/term

Reproduction repo

How to reproduce

  1. Create a collection Trainer-Led Learning.
  2. Scaffold views
  3. Configure its route to /trainer-led-learning/{slug}
  4. Create a taxonomy Staff Groups.
  5. Create views /trainer_led_learning/staff_groups/{index, show}.antlers.html
  6. In the index view, loop over the taxonomy:
<ul>
    {{ taxonomy:staff_groups collection="trainer_led_learning" }}
        <li><a href="{{ url }}">{{ title }}</a></li>
    {{ /taxonomy:staff_groups }}
</ul>

Expected output:

<ul class="list-disc">
    <li><a href="http:/example.com/trainer-led-learning/staff-groups/term-1">{{ title }}</a></li>
    <li><a href="http:/example.com/trainer-led-learning/staff-groups/term-2">{{ title }}</a></li>
</ul>

Actual output:

<ul class="list-disc">
    <li><a href="http:/example.com/trainer_led_learning/staff-groups/term-1">{{ title }}</a></li>
    <li><a href="http:/example.com/trainer_led_learning/staff-groups/term-2">{{ title }}</a></li>
</ul>

Logs

Environment

Environment
Application Name: Statamic
Laravel Version: 11.41.3
PHP Version: 8.2.27
Composer Version: 2.8.4
Environment: local
Debug Mode: ENABLED
URL: taxonomy-slug-bug.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 0
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.46.1 Solo

Installation

Fresh statamic/statamic site via CLI

Additional details

If this is indeed a bug, I'm happy to look into it 😃

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions