As I’m starting to work on more custom navigation and I have run into the problem that I don’t know how to link to stuff so that it works on both the main page and translated page. I also would like the link to survive if the slug of target were to change.
For example I am creating a mega-menu and I have a button that I want to link to an archive page for a custom post type, how can I create the link so that it works both when the header is on the Spanish and English version of any page?
I am assuming I could use twig to do something like the following, but that’s a lot of work and is hard to maintain, surely there is a better way.
{% set userlang = localization.user_locale %}
{% set lang = localization.locale %}
{% if userlang starts with 'es' %}/juegos/
{% elseif userlang starts with 'en' %}/en/games
{% elseif lang starts with 'es' %}/juegos
{% elseif lang starts with 'en' %}/en/games
{% else %}/jugeos
{% endif %}
