Issue with routing on multilingual

Hello ! I’m currently building a multilingual blog and i’m quite lost with routing.

I don’t only need posts in a certain language (which can be achieved using tag filter on routing) but also the global context of the website, including categories url on menu.

So, i made a template (hbs) for each categories where i filter directly on the post loop. Which is working well actually.

Now my problem is my routing. It’s looking like that :

routes:

collections:
/:
permalink: /{slug}/
template: index
filter: ‘tag:fr’
/tips-tactics-strategies/:
permalink: /tips-tactics-strategies/
template: categories/strategies
/product/:
permalink: /product/
template: categories/product
/news/:
permalink: /news/
template: categories/news
/guides/:
permalink: /guides/
template: categories/guides

/en/:
permalink: /en/{slug}/
template: multilingual/en/index
filter: ‘tag:en’
/en/tips-tactics-strategies/:
permalink: /en/tips-tactics-strategies/
template: multilingual/en/categories/strategies
/en/product/:
permalink: /en/product/
template: multilingual/en/categories/product
/en/news/:
permalink: /en/news/
template: multilingual/en/categories/news
/en/guides/:
permalink: /en/guides/
template: multilingual/en/categories/guides

taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/

It’s a bit overkill but i want all the website (menu, footer…) to be localized and it did’nt saw how to make conditions on lang variable…{{#has {{lang}}=“en”}}{{/has}} do not seems to be an option. Or maybe i’m doing it wrong :slight_smile:

The problem with this routing is that when im on /en/ , the post url are redirected to /tipcs-tactics-strategies/…because of routing priority i guess.

Any help on those subjects ? Thank you very much :)

Hey @alexsnti,

It looks like from your collections definition you’re not fully filtering the posts into the collection pages properly. Some of the collection routes you defined don’t have any filters. You should take advantage of tags more to allow you to filter content better.

Also you might want to look into channels, where you can filter content on pages but allow posts to co-exist in other channels and collections:
https://ghost.org/docs/api/v3/handlebars-themes/routing/channels/

Hope this helps! :blush:

Hey David ! Thank you for this hint, now everything is working ! I used channels as suggested and collections.

Thank you for the help !

1 Like

No problem! Glad I was able to help :blush: