It can help to make more flexible default templates for multilanguage sites (e.g. hreflang link attributes in html headers).
No, but the langugages are sorted, so if you want āthe firstā you can always do index .Site.Home.AllTranslations 0
.
Great! Thanks.
I think of if we can get the value of ādefaultContentLanguageā will be better.
If it can help you (in the context of multi-language sites), I did my hreflang this way, ranging over existing translations
Thanks! @martignoni
{{ if .Site.IsMultiLingual }}
<a href="{{ .Site.BaseURL }}{{.Site.Language }}" class="link white">
Jenkins X
{{ .Page.Lang }}
</a>
{{ else }}
<a href="{{ .Site.BaseURL }}" class="link white">
Jenkins X
</a>
{{ end }}
This is what I want. But here is a problem, it will get 404 when current pageās language is the defaultContentLanguage
. So I need to know the default language.
Looking at your code, it seems what you want isnāt exactly related to hreflang
, and seems instead like a language switch.
Did you have a look here: Language switcher in menu?
Thanks for your reply. Thatās very good. Maybe you can contribute it to gohugoTheme.
This is planned, but I think my theme is not totally ready for publication yet.
Is this still the case: site.DefaultContentLanguage
canāt be read from templates?
The defaultContentLanguage
in the site configuration is not exposed to the templates.