I am very new to this CMS and I was able to set it up, import some content from csv files.

I have set up templates and right now if someone clicks on the article, the URL is www.example.com/articles/{slug} of the article. This is all fine if I wasn't migrating from another system and we have a ton of articles and the URL was based on SEO requirements.

I have set up a channel type and one of the fields is Category type. I have 2 more category type fields but I don't use them to create the URL.

Here is the screenshot of what it looks like enter image description here A lot of content from olden days doesn't have the second category (so would just belong to Analog/ Mixed Signal ICs) but the newer content (from last 3 odd years most likely has it). So when the Url is display I want the URL to be either www.example.com/Analog_Mixed_Signal_ICs/Title or www.example.com/Analog_Mixed_Signal_ICs/Amplifiers/Title

I am not sure if this simple or complex but I would appreciate if someone can tell me how to achieve this.

1 Answer 1


I wouldn't normally set up a site like this — but given your setup, the following should work.

  • In the category settings, make sure that your category has 'Entries in this section have their own URLs' checked.
  • Set your category url format to:
    • top-level: {slug}
    • nested categories: {parent.uri}/{slug}
  • Set your article entry url format in the channel settings to {category.last.uri}/{slug} (where 'category' is the handle of your category field.)

Note the use of last. Categories will be returned as an Element Criteria Model which behaves much like an array (even if there is only one defined). The use of last will return the last category element, which should be the uri pattern that you're looking for.

Of course, if you have other routes in the CMS you will have to be careful about routing conflicts.

As a side note, you might want to consider using a 'structure' instead of 'categories'. I commonly use a single structure that represents all of the top level pages in a site, using Entry Types to distinguish the various field requirements and page layouts. You can then include the appropriate template layout automatically based on 'entry.type'. Likewise, you can use this structure to easily generate your site nav, and be fairly confident you won't run into any routing conflicts. The only reason I mention this is that you seem to already be heading in this direction with your current setup.

Edit: I might also add that you will want to make your category field required, otherwise there will be no route to the article in question.

  • I don't really have the option to change the way the site is set up. We are bring over the old structure to new CMS and really don't want to deal with a ton of 404s & code for 301s hence this route. I have uploaded some content which only has 1 level content and when I tried the method you mentioned (googled it before and thought I had the right answer, I got Failed Tasks). Can you expand more about the structure method? I am still in a phase I have to test the hell out of it before I can start importing 80K html items (thats another headache).
    – Subrato M
    Commented May 11, 2016 at 2:04
  • What didn't work exactly? What do you mean failed tasks? If you use a structure instead of categories, just use an 'entries' field instead of a 'categories' field. Your structure would match the category structure one-for-one. And you can use it in almost exactly the same way. The only difference is that when you link a structure entry it does not automatically link the parent entries like a category would. Don't know if that's important to you or not. Commented May 11, 2016 at 2:27
  • I don't have access to that screenshot of what happens when I set up the url structure as you mentioned. I will take a screenshot as soon as I can and add it. It doesn't show me anything other than Failed Tasks on the left side nav. I assume the failed tasks are basically telling me that the URL structure I chose didn't work when it tried recreating article slugs. I am not sure if the structure will work or not. I am going to run an import (from csv files) and see what happens. I am not against creating a better way of handling the URL with the same URL structure.
    – Subrato M
    Commented May 11, 2016 at 2:35
  • Ah.. you must be referring to the import plugin? Might be easier to chat in the craft slack channel for a moment. Feel free to message me there if you like (username is just douglas). Commented May 11, 2016 at 2:39
  • Yes, exactly! I couldn't remember the exact details so I didn't want to add unconfirmed information. I will get into chat and send you a message there
    – Subrato M
    Commented May 11, 2016 at 2:44

Your Answer

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

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