There are many aspects to building a site with content localized into multiple languages. To optimize SEO, your page needs link elements that point to the alternate localized versions.
Remix has a links function, however, this function does not include data from the loader. If you have dynamic routes, such as a blog with articles and the url based on the slug /blog/some-article, using the links function won’t work, since you cannot access the dynamic part of the route to generate your localized link tags.
The solution is to use Remix’s meta function, instead. The meta function gets passed the data from the loader, and you can use the tagName property to render a <link> tag. Google’s guidelines state that each language version must list itself as well as all other language versions, so you need to include all the links for all the languages.
Here’s how to do it:
Utility function
Since all of your localized pages will need to include these links, you should create a utility function that returns these link tags for you.
And then import that into your route meta functions.