mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-30 03:03:09 +00:00
theme: announce translations as alternate links #422
This commit is contained in:
parent
8e7bbf473e
commit
8882e2eff3
4 changed files with 45 additions and 24 deletions
|
@ -27,6 +27,8 @@ theme = "hugo-theme-relearn"
|
||||||
# the main language of this site; also an automatic pirrrate translation is
|
# the main language of this site; also an automatic pirrrate translation is
|
||||||
# available in this showcase
|
# available in this showcase
|
||||||
languageCode = "en"
|
languageCode = "en"
|
||||||
|
# make sure your defaultContentLanguage is the first one in the [Languages]
|
||||||
|
# array below, as the theme needs to make assumptions on it
|
||||||
defaultContentLanguage = "en"
|
defaultContentLanguage = "en"
|
||||||
# if you want to get rrrid o' ourrr pirrrates nonsense uncomment th' next line
|
# if you want to get rrrid o' ourrr pirrrates nonsense uncomment th' next line
|
||||||
# disableLanguages = ['pir']
|
# disableLanguages = ['pir']
|
||||||
|
|
|
@ -20,6 +20,11 @@ After learning [how Hugo handle multilingual websites](https://gohugo.io/content
|
||||||
|
|
||||||
For example with current English and Piratized English website.
|
For example with current English and Piratized English website.
|
||||||
|
|
||||||
|
{{% notice note %}}
|
||||||
|
Make sure your default language is defined as the first one in the `[Languages]` array, as the theme needs to make assumptions on it
|
||||||
|
{{% /notice %}}
|
||||||
|
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# English is the default language
|
# English is the default language
|
||||||
defaultContentLanguage = "en"
|
defaultContentLanguage = "en"
|
||||||
|
|
|
@ -4,20 +4,24 @@
|
||||||
{{- range .Data.Pages }}
|
{{- range .Data.Pages }}
|
||||||
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
|
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
|
||||||
<url>
|
<url>
|
||||||
<loc>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</loc>{{ if not .Lastmod.IsZero }}
|
<loc>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</loc>
|
||||||
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
|
{{- if not .Lastmod.IsZero }}
|
||||||
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
|
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>
|
||||||
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
|
{{- end }}
|
||||||
<xhtml:link
|
{{- with .Sitemap.ChangeFreq }}
|
||||||
rel="alternate"
|
<changefreq>{{ . }}</changefreq>
|
||||||
hreflang="{{ .Lang }}"
|
{{- end }}
|
||||||
href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}"
|
{{- if ge .Sitemap.Priority 0.0 }}
|
||||||
/>{{ end }}
|
<priority>{{ .Sitemap.Priority }}</priority>
|
||||||
<xhtml:link
|
{{- end }}
|
||||||
rel="alternate"
|
{{- if .IsTranslated }}
|
||||||
hreflang="{{ .Lang }}"
|
{{- range $index, $trans := .AllTranslations }}
|
||||||
href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}"
|
{{- if eq $index 0 }}
|
||||||
/>{{ end }}
|
<xhtml:link rel="alternate" hreflang="x-default" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}" />
|
||||||
|
{{- end }}
|
||||||
|
<xhtml:link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}" />
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
</url>
|
</url>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -17,6 +17,15 @@
|
||||||
{{- $title = printf "%s%s" $title .Site.Title }}
|
{{- $title = printf "%s%s" $title .Site.Title }}
|
||||||
<title>{{ $title }}</title>
|
<title>{{ $title }}</title>
|
||||||
|
|
||||||
|
{{- if .IsTranslated -}}
|
||||||
|
{{- range $index, $trans := .AllTranslations }}
|
||||||
|
{{- if eq $index 0 }}
|
||||||
|
<link href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename) }}" rel="alternate" hreflang="x-default">
|
||||||
|
{{- end }}
|
||||||
|
<link href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename) }}" rel="alternate" hreflang="{{ .Language.Lang }}">
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
{{- if not (and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }}
|
{{- if not (and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- range .AlternativeOutputFormats }}
|
{{- range .AlternativeOutputFormats }}
|
||||||
|
@ -29,6 +38,7 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if and (ne .Site.Params.disableSeoHiddenPages true) (ne .Site.Params.disableSearchHiddenPages true) }}
|
{{- if and (ne .Site.Params.disableSeoHiddenPages true) (ne .Site.Params.disableSearchHiddenPages true) }}
|
||||||
{{- range .AlternativeOutputFormats }}
|
{{- range .AlternativeOutputFormats }}
|
||||||
{{- if eq .Name "SEARCHPAGE" }}
|
{{- if eq .Name "SEARCHPAGE" }}
|
||||||
|
|
Loading…
Reference in a new issue