My routes.yaml files is getting longer and I wonder if and how I can optimized it. Also does the size of this file impacts performances?
I chose to go with the following for my collections and taxonomies:
collections:
/:
permalink: /articles/{primary_tag}/{slug}/
template:
- index
taxonomies:
tag: /topics/{slug}/
author: /authors/{slug}/
In order to avoid 404 pages if someone edits the URL to go up a level I also created routes like:
— Route for Articles (Will show all articles)—
/articles/:
controller: channel
order: published_at desc
data:
post: page.articles
template: category-page
and
— Route for PrimaryTag1 —
/PrimaryTag1/:
controller: channel
order: published_at desc
filter: tag:[PrimaryTag1]
data:
post: page.PrimaryTag1
template: category-page/articles/PrimaryTag1/:
controller: channel
order: published_at desc
filter: tag:[PrimaryTag1]
data:
post: page.PrimaryTag1
template: category-page— Route for PrimaryTag2 —
/PrimaryTag2/:
controller: channel
order: published_at desc
filter: tag:[PrimaryTag2]
data:
post: page.PrimaryTag2
template: category-page/articles/PrimaryTag2/:
controller: channel
order: published_at desc
filter: tag:[PrimaryTag2]
data:
post: page.PrimaryTag2
template: category-pageand so on for other primary tags…
I created a page for “articles” and a page for each primary tag.
The template used for those pages is the same as the one used for the taxonomies “/topics/{slug}/”.
I also have a page for “Topics” (/topics/) that will display all tags.
I created the /PrimaryTag1/ slug so those major topics can be accessed easily with mysite.com/primarytag1/
Is it too much? Will that affect loading speeds? Is there any improvement I can make?
Cheers,