Working on my first EE site and I’m stuck on how to structure my templates for the blog categories that results in a clean URL structure. Here’s what I’m trying to achieve (note: index page is my blog roll):
I’ve heard that it’s tricky trying to manage segment 1 urls, so not sure if I need to forego this whole idea and stick with more native urls.
I’m happy to continue to chase down solutions if I can be pointed in the right direction. Also, I can paste in some template code or answer questions about how I have EE configured if needed. I appreciate anyone’s time with this, thanks!
Welcome to the forums
Is your site primarily a blog? If it is you could use your default template group index file to list category data.
In your index template you can do something like this:
{if segment_1 == ""}
Home page content
{/if}
{if segment_1 == "catgeory"}
Category content
{/if}
That will give you a category URL like example.com/category/my-category
Another approach is to use a template group called /blog and use that index template so you have a category URL like example.com/blog/category/my-category
Another approach is to use Template routes - https://docs.expressionengine.com/latest/templates/routes.html - these allow you to create custom URL’s that bypass the normal /template-group/template method.
All good ideas Rob, thank you for sharing some options. My site is primarily a blog so I see how I could use conditional statements to structure the index template. I’m going to dig into routes as well to see how they could work.
I was able to work up a solution which doesn’t give me originally what I wanted but it functionally works. I essentially opted for a template group called “category” and use that index to render a filtered list of posts based on the category. That nice thing about this solution is it cleanly separates my templates so I can better manage the main index and the category index.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.