1

I have created a new Category on a Craft 3 website but it will not load the template specified. Have other categories all working fine and can't get this one working at all.

Category Config below

enter image description here

I expect this to load my template /pupil-of-the-month/index.html

As per the below image in my templates folder.

enter image description here

But when I click on the category url - http://local.domain.com/pupil-of-the-month/class/p1

I get a not found error -

Template not found: pupil-of-the-month/class

Why is this Category not following the template specified in the admin settings?

  • I answered prematurely—I'm not sure how class is sneaking in at the end of the template it's looking for. 🤔 – August Miller Jun 18 '18 at 16:37
  • Yep it’s really got me too. I had the exact same set up on a Craft 2 site so not sure what’s going on here. – mmc501 Jun 18 '18 at 17:37
  • Can you double-check the value stored in the database? I want to make sure you're seeing the right value in the CP. The categorygroups_sites table has a column named template, which should contain this value. – August Miller Jun 18 '18 at 20:31
  • Yep Database looks good. urlFormat - pupil-of-the-month/class/{slug} template - pupil-of-the-month/index – mmc501 Jun 18 '18 at 20:36
1

The template path specified in the admin should point to a single file, not a directory.

index files are only loaded when the Craft router falls all the way through element URIs and starts to look in your templates folder—in your case, that would be local.domain.com/pupil-of-the-month.

I suspect the confusion lies in that the router does eagerly look inside a directory for index.* templates in some narrow cases (as stated above), but that the pattern is not adopted by Category/Section/Tag settings.

See the official Routing Docs for more information about the process Craft uses to resolve the template for a request.

  • The template path to the directory works for all my other Category Groups, just not sure what’s going on with this one. I added /index.html to the end but same error message – mmc501 Jun 18 '18 at 17:37
0

Discovered what the issues was - it was my actual Category Names - the Class names which I had called, P1, P2, P3, P4 etc, which had a slug of p1, p2 etc.

Craft was picking those up as page numbers - and trying to route for that.

Discovered it when I had created an entry in a Structure with the title P1 which wasn't loading either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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