Is it possible to use category_url_title in the first segment without having to create a template group for each category? I'd just like to link to categories on the fly using the first segment (site.com/news, site.com/athletics) and using just one template group. Possible?
2 Answers
Yes. I've touched on it in this answer using segment_2, but the same is true for segment_1 - you just have to rely on the default template group and the index template. There may be a lot of pages routing through it, so lot's of conditionals on where it should go/do (maybe embeds to different category templates, or they all look the same pulling in different data). You may get issues if you have strict URLs as it may encounter 404, I just tested it and needed to disable strict URLs in template preferences. Utilise Seg2Cat to convert urls to IDs.
Ensure you don't get a clash with an existing template group or template name.
Edit:
Had another build with Strict URLs set and had this in the .htaccess:
RewriteCond $1 ^(sitemap_index\.xml|sitemap\.xml|product-feed\.xml) [NC]
RewriteRule ^(.*)$ /root/$1 [L]
Granted this is to access a specific page (removing the template group) not a category, but if the first part of this answer doesn't work or you need strict URLs give the above a go, where you spcifically name the template to go to in the rewrite rule.
Not utilised it before, but template routes might also be worth exploring.
I was able to solve this easily using Resource Router. In my master config file I added the following and it works like a charm:
$env_config['resource_router'] = array(
':category_url_title' => 'category/index',
':category_url_title/:pagination' => 'category/index',
);