0

I'm using pathauto on a D8 site successfully for pattern type Content using a pattern like this:

[node:content-type]/[node:title]

But I'm not having any luck at all when trying to use it for pattern type Taxonomy term using a pattern like this:

[term:vocabulary]/[term:name]

I just keep getting /taxonomy/term/123 instead of /taxonomyname/taxonomyterm

I have searched and searched and every article I find only covers the tokens for Content, not Taxonomy. I did find one youtube video that covered it in D7 and the pattern was identical to mine, yet his worked but mine doesn't. I've cleared caches and even tried bulk generate to no avail. But Taxonomy (list) pages don't create aliases though, so I'm wondering if that has something to do with it.

2 Answers 2

1

OK, I figured this out, and the funny thing is, I had it right from the start. The pattern I used above is correct (what I wanted). The only problem I created for myself was, I created the taxonomy terms before I created the pattern for it, so all those terms needed to have aliases generated for them. Hint: bulk generate

When I generate new terms now, I see at the bottom of the form there is a checkbox (default is checked) to Generate automatic URL alias. And that does in fact create a new alias because I tested it.

If you find yourself in the same position, go to /admin/config/search/path/update_bulk and select the Taxonomy term checkbox, and then the Generate a URL alias for un-aliased paths only radio button. Alternatively, you can check the Regenerate URL aliases for all paths if you think you have some existing alias that may be wrong to changes you've made to taxonomy.

0

Have you actually tried to visit /taxonomyname/taxonomyterm?

The /taxonomy/term/123 isn't actually a taxonomy page, it is a Views showing content tagged with the term from the URL. It's a separate thing.

What do you expect to see on that page? Just the term name and description? That should work with the Pathauto as you have set it up.

If you want to see the content, like that Views page, you can use the Taxonomy term Views, Duplicate it and disable the original just for future reference, and modify the Contextual filters and Path to your preference.

You will need to add the Relationship to the term so you could use the Taxonomy: Name Contextual filter to get the term name in the URL.

You can also set up aliases for the default Taxonomy term Views so they use names, but I think it would have to be done manually, and isn't at all elegant/smart solution. It make more sense to set up the Views as you intend it to be used.

4
  • prkos, thank you for the assit, here's more info... Visiting /taxonomyname/taxonomyterm just returns a 404 error, even though I agree it should at least return the term name and description. I want it to work just like the Taxonomy view, which I didn't realize existed and explains why no one covers it in pathauto tutorials. However, if I can find that youtube video where someone did it in D7, I'll share that. Manually setting up aliases is way too much work, I'll try the view method you described and follow up with how I make out. Thanks again, Rick
    – Rick_P
    Jun 20, 2019 at 15:18
  • Here's an interesting note, I disabled the default Taxonomy view without duplicating it to test what would happen if there was no view at all, and while I got no list of matching items, I still got a blank page with the term name and the URL is /taxonomy/term/7 so there is more to the URL than just what is configured in the view.
    – Rick_P
    Jun 20, 2019 at 15:24
  • I'm not having much luck using Views, which may be due to not setting up the Contextual filters and Relationships correctly. There are a lot of configuration options and I tried a few things based on prior knowledge of Views, and I have been able to get results to return on the page, but the URL hasn't changed at all, even though I have tried a few things in the Page settings / Path section of the View. It seems to me that pathauto should be able to override the URL path of the default View anyway, so this (to me) seems like overkill to achieve friendly URLs from taxonomy pages.
    – Rick_P
    Jun 20, 2019 at 15:58
  • Can you post your Pathauto taxonomy configuration? It's not a blank page if it's showing the term name. It would probably show any fields associated with that term. You need to have the path start with something solid, some word, before you can add contextual values to it, so in the end it will be /someword/taxonomyname/taxonomyterm. You have to have two Contextual filters, both working, one for Vocabulary, the other for term name, then you change your Path setting to /someword/%/%, each % is one contextual value. Search for taxonomy term name as contextual in views for detailed steps.
    – prkos
    Jun 20, 2019 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.