Improves i18n - Links point to localized versions of the pages

E.g. "Contact" links to /contact by default or when defaultLanguageContent=en.
If the user selects any other language (e.g Es), the link points to "/es/contact".
The Call to Action button also points to the localized version of the Contact page.
This commit is contained in:
Xavi Aznar 2019-06-09 00:35:16 +02:00
parent 24fcdf79d6
commit 5205011fc1
2 changed files with 5 additions and 5 deletions

View file

@ -31,7 +31,7 @@
<div class="section bg-white shadow text-center">
{{ with .Site.Params.cta.title }} <h2 class="mb-4">{{ . }}</h2> {{ end }}
{{ with .Site.Params.cta.description }} <p class="mb-4">{{ . }}</p> {{ end }}
<a href="{{ with .Site.Params.cta.btnURL}}{{ . | absURL }}{{ end }}" class="btn btn-primary">{{ with .Site.Params.cta.btnText}}{{ . }}{{ end }}</a>
<a href="{{ with .Site.Params.cta.btnURL}}{{ . | relLangURL }}{{ end }}" class="btn btn-primary">{{ with .Site.Params.cta.btnText}}{{ . }}{{ end }}</a>
</div>
</div>
</div>

View file

@ -1,5 +1,5 @@
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="{{ .Site.BaseURL }}">{{ .Site.Params.logo }}</a>
<a class="navbar-brand" href="{{ .Site.BaseURL | relLangURL }}">{{ .Site.Params.logo }}</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#navigation"
aria-controls="navigation" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -8,7 +8,7 @@
<div class="collapse navbar-collapse text-center" id="navigation">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link text-dark" href="{{ .Site.BaseURL }}">{{ .Site.Params.home }}</a>
<a class="nav-link text-dark" href="{{ .Site.BaseURL | relLangURL }}">{{ .Site.Params.home }}</a>
</li>
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
@ -19,13 +19,13 @@
</a>
<div class="dropdown-menu" >
{{ range .Children }}
<a class="dropdown-item" href="{{ .URL }}">{{ .Name }}</a>
<a class="dropdown-item" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
{{ end }}
</div>
</li>
{{ else }}
<li class="nav-item">
<a class="nav-link text-dark" href="{{ .URL }}">{{ .Name }}</a>
<a class="nav-link text-dark" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
</li>
{{ end }}
{{ end }}