Link to i18n content page from layout

Hi all. This is probably a follow-up of this question, but I couldn’t find anything fitting in the docs or the forum.

I’m trying to link from a layout file to a page that’s available in multiple languages. From what I took away in the Cross references docs, this works:

<a href="{{ relref . "contact.md" }}">Kontakt</a>

…which will only work for the default language, but not for e.g. contact.fr.md.

Are cross references even the correct approach if I just want a simple link to a content page from a layout file? :smile_cat:

I was figuring this out and came up with this solution:

<a href="{{ relref . "contact/" }}">Kontakt</a>

You also need to move your contact.md and contact.fr.md to

contact/_index.md
contact/_index.fr.md

Additionally if I understand ref and relref correctly the ref function should be used by default. The relref function is useful only in cases when the “relative” part is important. For example when the link will link to different pages when used in different sections.