Link to languages.languages.en.baseurl

Hi,
my website is mainly made in Polish. I am adding the English part to it, but this will be English independent to Polish. Content is not translated, the English version will hold text written for English readers were Polish, for Polish readers.

I got in config:

[languages]
  [languages.pl]
    baseURL = "https://dariusz.wieckiewicz.org/"
[languages.en]
    baseURL = "https://dariusz.wieckiewicz.org/en/"

On polish part I would like to get a baseURL from [languages.en] and on English from [languages.pl]

{{ range $.Translations }} is not the right approach, as this only work for the homepage. Permalink will not show on posts, as they are not a translated version.

I could do this hardcoded to display on Polish website link to /en and on English, to main, however that’s not good approach, as when site is run locally, Polish is served on port 1313 and English on 1314, hence links will not work locally.

Below code work for homepage with different ports, however, as mentioned above, this is not what I am looking for.

<div id="language">
  {{ range $.Translations }}
    {{ if eq .Language.LanguageName "English" }}
      <a title="{{ .Language.LanguageName }}" href="{{ .Permalink }}">{{ T "LanguageText" }}</a>
    {{ else if eq .Language.LanguageName "Polish" }}
     <a title="{{ .Language.LanguageName }}" href="{{ .Permalink }}">{{ T "LanguageText" }}</a>
    {{ else }}
    {{ end }}
  {{ end }}
</div>

Though it can be taken like .Params are (.Params.value) but is not working like that.

Maybe my logic on that is different and cannot achieve what I want. I will probably finish with hard-codding (that will not work in local environment).

Any advise appreciated.


Shortly speaking,
On PL website paste {{ .Site.BaseURL }} for English (that on local env. will be localhost:1314/en/)
On EN website paste {{ .Site.BaseURL }} for Polish (localhost:1313) inside <a href>

You can try something like:

{{ range site.Home.Translations }}
    {{ .Permalink }}
{{ end }}
1 Like

Perfect, thank you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.