I am wanting to get rid of template group names in the URL and basicly get more control over the URL structure.

Maybe template routes will now allow me to do what I want but not sure I understand how that works.




where Double King is the entry title

I want: myhotel.com/room/double_king or even myhotel.com/double_king

Can I do that with template routes?



3 Answers 3


I'm not sure if template routes would work as I've not had chance to use them yet, but you could achieve it without Structure by using some basic routing in your template (which may be effectively the same as the new template routing functionality).

Basically, you could change your template group to room. Then you could run a conditional on {segment_2} in the index template.

{if segment_2}

This approach would work, but isn't ideal because of the way embeds and conditionals are parsed in EE - you'd be adding overhead to the server because it would read through both conditions, parsing both your embedded templates before deciding which one it doesn't want.

You could improve the performance by using IfElse which parses the conditionals differently, and avoid using the embedded templates, instead including your channel entries tags within the index template.

  • 1
    Just wanted to correct that it would not parse both of your embedded templates. If it were module tags, it would, but templates are all parsed separately, and only after the parent's parsing is complete. That makes the above pattern a good choice when you need completely different tags based on certain conditions, as it will only parse the one on the child template that passes the conditional. Commented May 1, 2014 at 21:59
  • Ah I see - that's great - thanks for the clarification :-) Commented May 1, 2014 at 22:37

Yes, Template Routes should be able to accommodate. Given a route rule to your room_types/room template of:


then http://example.com/room/double_king would go to that template, and populate the {segment:room} variable with "double_king".

If you want to go to single segments:


Though the trick here is if you have other valid first segments that need to go elsewhere. You would set your routes in the order of most specific to least specific, so that if you wanted http://example.com/book-it to go to another template, you'd want to create a route rule of /book-it in a higher position.


You might want to look at Structure - http://buildwithstructure.com/

It bypasses the template/group template URL structure and allows you to create any URL you like. Also makes managing a big page tree with many levels very easy, and help generate navigation and breadcrumbs too.

  • Why would someone downvote this answer? Commented Apr 27, 2014 at 4:59
  • 1
    Seems a sensible enough answer to me but I guess it doesn't actually answer the question which was 'can it be done with template routes'. Commented Apr 28, 2014 at 21:03

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.