Files
rancher-docs/layouts/partials/seo.html
T

136 lines
4.7 KiB
HTML

<title>
{{ with .Params.metaTitle }}
{{ . }}
{{ else }}
{{ if eq .Section "tags" }}
{{ .Title }} Blog Posts by Rancher
{{ else }}
Rancher Docs: {{ .Title }}
{{ end }}
{{ end }}
</title>
{{- .Scratch.Set "permalink" .Permalink -}}
{{- if (and .Pages (not .IsHome)) -}}
{{/*
Hugo doesn't generate permalinks for lists with the page number in them,
which makes all the pages of a list look lik the same page to a search
engine, which is bad.
*/}}
{{- $by := .Params.pageBy | default .Site.Params.pageBy | default "default" -}}
{{- $limit := .Site.Params.pageLimit | default 10 -}}
{{- if (eq .Site.Params.pageBy "newest") -}}
{{- $paginator := .Paginate .Pages.ByDate.Reverse $limit -}}
{{- .Scratch.Set "paginator" $paginator -}}
{{- else if (eq .Site.Params.pageBy "title") -}}
{{- $paginator := .Paginate .Pages.ByTitle $limit -}}
{{- .Scratch.Set "paginator" $paginator -}}
{{- else -}}
{{- $paginator := .Paginate $limit -}}
{{- .Scratch.Set "paginator" $paginator -}}
{{- end -}}
{{- $paginator := .Scratch.Get "paginator" -}}
{{- if (gt $paginator.PageNumber 1) -}}
{{ .Scratch.Set "permalink" ($paginator.URL | absURL) }}
{{- end -}}
{{ with $paginator.Prev -}}
<link rel="prev" href="{{ .URL | absURL}}" />
{{- end }}
{{ with $paginator.Next -}}
<link rel="next" href="{{ .URL | absURL}}" />
{{- end }}
{{- end -}}
{{ $permalink := .Scratch.Get "permalink" }}
{{ if .Params.canonical }}
<link rel="canonical" href="{{ with .Params.canonical }}{{ . }}{{ end }}">
{{ end }}
{{ if .RSSLink -}}
<link href="{{ .RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Title }}" />
{{- end }}
{{ if eq .Section "tags" }}
<meta name="description" content="Learn more about {{ .Title | pluralize }} from Rancher, the experts in container orchestration.">
{{ else }}
<meta name="description" content="{{ with .Params.metaDescription }}{{ . }}{{ else }}{{ .Description }}{{ end }}"/>
{{ end }}
<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:description" content="{{ with .Params.metaDescription }}{{ . }}{{ else }}{{ .Description }}{{ end }}" />
<meta name="twitter:title" content="{{ .Title }}" />
<meta name="twitter:site" content="{{ .Site.Params.twitter }}" />
<meta name="twitter:creator" content="{{ .Site.Params.twitter }}" />
<!-- OG data -->
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:title" content="{{ .Title }}">
<meta property="og:description" content="{{ with .Params.metaDescription }}{{ . }}{{ else }}{{ .Description }}{{ end }}">
<meta property="og:url" content="{{ $permalink }}" />
<meta property="og:site_name" content="{{ .Site.Title }}" />
<meta property="og:image" content="{{.Site.BaseURL}}{{ with .Params.image }}{{ . }}{{ else }}/img/logo-square.png{{ end }}" />
{{ range .Params.categories }}<meta property="article:section" content="{{ . }}" />{{ end }}
{{ if isset .Params "date" }}<meta property="article:published_time" content="{{ time .Date }}" />{{ end }}
{{- if .IsHome -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "{{ $permalink }}",
"name": "{{ .Site.Title }}",
"author": {
"@type": "Organization",
"name": "Rancher Labs"
},
"description": "{{ .Site.Params.description }}"
}
</script>
{{- else if .IsPage -}}
<script type="application/ld+json">
{{- if eq .Section "post" -}}
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"headline": "{{ .Title }}",
"genre": "{{ range .Params.categories }}{{ . }}{{ end }}",
"url": "{{ $permalink }}",
"datePublished": "{{ time .Date }}",
{{ with index .Site.Data.authors .Params.author }}
"author": {
"@type": "Person",
"name": "{{ .name }}"
},
{{ end }}
"description": "{{ with .Params.metaDescription }}{{ . }}{{ else }}{{ .Description }}{{ end }}"
}
{{- else -}}
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "{{ $permalink }}",
"name": "{{ .Title }}",
{{ if .Params.author -}}
{{ $author := (index .Site.Data.authors .Params.author) }}
"author": {
"@type": "Person",
"name": "{{ $author.name }}"
},
{{- else }}
"author": {
"@type": "Organization",
"name": "Rancher Labs"
},
{{- end }}
"description": "{{ .Site.Params.description }}"
}
{{- end -}}
</script>
{{ end }}