mirror of
https://github.com/trwnh/hugo-theme-paradox.git
synced 2024-11-24 10:21:21 +00:00
Improve metadata and make it more robust
This commit is contained in:
parent
3fc0ddf5d1
commit
653247d765
|
@ -1,37 +1,78 @@
|
||||||
{{ $icon := "images/icon.png" | absURL }}
|
{{ "<!-- title -->" | safeHTML }}
|
||||||
<link rel="shortcut icon" href='{{ $icon }}' sizes="765x765">
|
|
||||||
{{ if .IsPage }}{{ with .Params.tags }}<meta name="keywords" content='{{ delimit . " "}}'>{{ end }}{{ end }}
|
|
||||||
{{ if .IsHome }}<title>{{ .Site.Title }}</title>
|
|
||||||
<title itemprop="name">{{ .Site.Title }}</title>
|
|
||||||
<meta property="og:title" content="{{ .Site.Title }}" />
|
|
||||||
<meta name="twitter:title" content="{{ .Site.Title }}" />
|
|
||||||
<meta itemprop="name" content="{{ .Site.Title }}" />
|
|
||||||
{{ else }}<title>{{ .Title }} | {{ .Site.Title }}</title>
|
|
||||||
<title itemprop="name">{{ .Title }} | {{ .Site.Title }}</title>
|
<title itemprop="name">{{ .Title }} | {{ .Site.Title }}</title>
|
||||||
<meta property="og:title" content="{{ .Title }} | {{ .Site.Title }}" />
|
<meta property="og:title" content="{{ .Title }}" />
|
||||||
<meta name="twitter:title" content="{{ .Title }} | {{ .Site.Title }}" />
|
<meta name="twitter:title" content="{{ .Title }}" />
|
||||||
<meta itemprop="name" content="{{ .Title }} | {{ .Site.Title }}" />{{ end }}
|
|
||||||
<meta name="application-name" content="{{ .Site.Title }}" />
|
<meta name="application-name" content="{{ .Site.Title }}" />
|
||||||
<meta property="og:site_name" content="{{ .Site.Title }}" />
|
<meta property="og:site_name" content="{{ .Site.Title }}" />
|
||||||
<meta name="description" content="{{ .Summary }}">
|
|
||||||
<meta itemprop="description" content="{{ .Summary }}" />
|
{{- with or .Description .Summary .Site.Params.description }}
|
||||||
<meta property="og:description" content="{{ .Summary }}" />
|
{{ "<!-- description -->" | safeHTML }}
|
||||||
<meta name="twitter:description" content="{{ .Summary }}" />
|
<meta name="description" content="{{.}}">
|
||||||
<base href="{{ .Permalink }}">
|
<meta itemprop="description" content="{{.}}" />
|
||||||
<link rel="canonical" href="{{ .Permalink }}" itemprop="url" />
|
<meta property="og:description" content="{{.}}" />
|
||||||
<meta name="url" content="{{ .Permalink }}" />
|
<meta name="twitter:description" content="{{.}}" />
|
||||||
<meta name="twitter:url" content="{{ .Permalink }}" />
|
{{ end -}}
|
||||||
<meta property="og:url" content="{{ .Permalink }}" />
|
{{ "<!-- url -->" | safeHTML }}
|
||||||
{{ with .Params.cover }}<meta itemprop="image" content="{{ . | absURL }}" />
|
<base href="{{ .Permalink | absURL }}">
|
||||||
<meta property="og:image" content="{{ . | absURL }}" />
|
<link rel="canonical" href="{{ .Permalink | absURL }}" itemprop="url" />
|
||||||
<meta name="twitter:image" content="{{ . | absURL }}" />
|
<meta name="url" content="{{ .Permalink | absURL }}" />
|
||||||
<meta name="twitter:image:src" content="{{ . | absURL }}" />{{ else }}
|
<meta name="twitter:url" content="{{ .Permalink | absURL }}" />
|
||||||
<meta itemprop="image" content='{{ $icon }}' />
|
<meta property="og:url" content="{{ .Permalink | absURL }}" />
|
||||||
<meta property="og:image" content='{{ $icon }}' />
|
|
||||||
<meta name="twitter:image" content='{{ $icon }}' />
|
{{- $cover := ($.Resources.ByType "image").GetMatch "{*cover*,*thumbnail*,*featured*}" -}}
|
||||||
<meta name="twitter:image:src" content='{{ $icon }}' />{{ end }}
|
{{ $icon := resources.GetMatch (default "" .Site.Params.icon) -}}
|
||||||
<meta property="og:updated_time" content={{ .Lastmod.Format "2006-01-02T15:04:05Z0700" | safeHTML }} />
|
{{- $staticIcon := "icon.png" | absURL -}}
|
||||||
{{ if isset .Params "date" }}<meta property="og:type" content="article" />
|
{{- with or .Params.cover $cover $icon }}
|
||||||
|
{{ "<!-- image -->" | safeHTML }}
|
||||||
|
<meta itemprop="image" content='{{ .Permalink | absURL }}' />
|
||||||
|
<meta property="og:image" content='{{ .Permalink | absURL }}' />
|
||||||
|
{{- with .Width }}
|
||||||
|
<meta property="og:image:width" content='{{ . }}' />
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Height }}
|
||||||
|
<meta property="og:image:height" content='{{ . }}' />
|
||||||
|
{{- end }}
|
||||||
|
<meta name="twitter:image" content='{{ .Permalink | absURL }}' />
|
||||||
|
<meta name="twitter:image:src" content='{{ .Permalink | absURL }}' />
|
||||||
|
{{- else }}
|
||||||
|
{{ "<!-- image -->" | safeHTML }}
|
||||||
|
<meta itemprop="image" content='{{ $staticIcon }}' />
|
||||||
|
<meta property="og:image" content='{{ $staticIcon }}' />
|
||||||
|
<meta name="twitter:image" content='{{ $staticIcon }}' />
|
||||||
|
<meta name="twitter:image:src" content='{{ $staticIcon }}' />
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*=== author ===*/}}
|
||||||
|
{{ with or .Params.author .Site.Params.author -}}
|
||||||
|
{{ "<!-- author -->" | safeHTML }}
|
||||||
|
<meta property="article:publisher" content="{{ . }}" />
|
||||||
|
<meta property="og:article:author" content="{{ . }}" />
|
||||||
|
<meta property="article:author" content="{{ . }}" />
|
||||||
|
<meta name="author" content="{{ . }}" />
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*=== published and updated ===*/}}
|
||||||
|
{{ "<!-- time -->" | safeHTML }}
|
||||||
|
{{- with .Date }}
|
||||||
|
<meta property="og:article:published_time" content={{ .Format "2006-01-02T15:04:05Z0700" | safeHTML }} />
|
||||||
|
<meta property="article:published_time" content={{ .Format "2006-01-02T15:04:05Z0700" | safeHTML }} />
|
||||||
|
{{ end -}}
|
||||||
|
{{ with .Lastmod -}}
|
||||||
|
<meta property="og:updated_time" content={{ .Format "2006-01-02T15:04:05Z0700" | safeHTML }} />
|
||||||
|
{{ end -}}
|
||||||
|
|
||||||
|
{{/*=== section and keywords ===*/}}
|
||||||
|
{{- with.Params.category -}}
|
||||||
|
<meta name="news_keywords" content="{{ . }}" />
|
||||||
|
<meta property="article:section" content="{{ . }}" />
|
||||||
|
{{- end -}}
|
||||||
|
{{- with .Params.tags }}
|
||||||
|
<meta name="keywords" content='{{ delimit . " "}}'>
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if isset .Params "date" -}}
|
||||||
|
{{ "<!-- article metadata -->" | safeHTML }}
|
||||||
|
<meta property="og:type" content="article" />
|
||||||
<script defer type="application/ld+json">
|
<script defer type="application/ld+json">
|
||||||
{
|
{
|
||||||
"@context": "http://schema.org",
|
"@context": "http://schema.org",
|
||||||
|
@ -39,60 +80,53 @@
|
||||||
"headline": {{ .Title }},
|
"headline": {{ .Title }},
|
||||||
"author": {
|
"author": {
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
"name": "{{ .Params.author }}"
|
"name": "{{ or .Params.author .Site.Params.author }}"
|
||||||
},
|
},
|
||||||
"datePublished": "{{ .Date.Format "2006-01-02" }}",
|
"datePublished": "{{ .Date.Format "2006-01-02" }}",
|
||||||
"description": {{ .Summary }},
|
"description": {{ or .Description .Summary }},
|
||||||
"wordCount": {{ .WordCount }},
|
"wordCount": {{ .WordCount }},
|
||||||
"mainEntityOfPage": "True",
|
"mainEntityOfPage": "True",
|
||||||
"dateModified": "{{ .Lastmod.Format "2006-01-02" }}",
|
"dateModified": "{{ .Lastmod.Format "2006-01-02" }}",
|
||||||
"image": {
|
"image": {
|
||||||
"@type": "imageObject",
|
"@type": "imageObject",
|
||||||
"url": "{{ with .Params.cover }}{{ . }}{{ end }}"
|
"url": "{{ with or .Params.cover $cover $icon }}{{ .Permalink | absURL }}{{ end }}"
|
||||||
},
|
},
|
||||||
"publisher": {
|
"publisher": {
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
"name": "{{ .Site.Title }}",
|
"name": "{{ or .Params.author .Site.Params.author .Site.Title }}",
|
||||||
"logo": {
|
"logo": {
|
||||||
"@type": "imageObject",
|
"@type": "imageObject",
|
||||||
"url": {{ $icon }}
|
"url": {{with $icon}}{{.Permalink}}{{else}}{{$staticIcon}}{{end}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{{ else }}<meta property="og:type" content="website" />
|
{{- else -}}
|
||||||
<meta name="author" content="{{ .Params.author }}" />
|
{{ "<!-- webpage metadata -->" | safeHTML }}
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
<script defer type="application/ld+json">
|
<script defer type="application/ld+json">
|
||||||
{
|
{
|
||||||
"@context": "http://schema.org",
|
"@context": "http://schema.org",
|
||||||
"@type": "WebSite",
|
"@type": "WebSite",
|
||||||
"url": {{ .Permalink }},
|
"url": {{ .Permalink }},
|
||||||
"name": "{{ .Title }}",
|
"name": "{{ .Site.Title }}",
|
||||||
"logo": {{ $icon }}
|
"logo": {{with $icon}}{{.Permalink}}{{else}}{{$staticIcon}}{{end}}
|
||||||
}
|
}
|
||||||
</script>{{ end }}
|
</script>
|
||||||
<meta property="article:publisher" content="{{ .Params.author }}" />
|
{{- end -}}
|
||||||
{{ with.Params.author }}<meta property="og:article:author" content="{{ . }}" />
|
|
||||||
<meta property="article:author" content="{{ . }}" />
|
{{/* auxiliary info */}}
|
||||||
<meta name="author" content="{{ . }}" />{{ end }}
|
{{ "<!-- site presentation -->" | safeHTML }}
|
||||||
{{ with.Params.category }}<meta name="news_keywords" content="{{ . }}" />
|
{{- with $icon }}
|
||||||
<meta property="article:section" content="{{ . }}" />{{ end }}
|
<link rel="shortcut icon" href='{{ .Permalink }}' sizes="{{.Width}}x{{.Height}}">
|
||||||
<meta property="og:article:published_time" content={{ .Date.Format "2006-01-02T15:04:05Z0700" | safeHTML }} />
|
{{- else -}}
|
||||||
<meta property="article:published_time" content={{ .Date.Format "2006-01-02T15:04:05Z0700" | safeHTML }} />
|
<link rel="shortcut icon" href='{{ $staticIcon }}' sizes="512x512">
|
||||||
<link rel="sitemap" type="application/xml" title="Sitemap" href="{{ .Site.BaseURL }}sitemap.xml" />
|
{{- end }}
|
||||||
{{ with .OutputFormats.Get "RSS" }}<link href="{{ .Permalink }}" rel="alternate" type="application/rss+xml" title="{{ $.Site.Title }}" />
|
|
||||||
<link href="{{ .Permalink }}" rel="feed" type="application/rss+xml" title="{{ $.Site.Title }}" />{{ end }}
|
|
||||||
<meta name="robots" content="index,follow" />
|
|
||||||
<meta name="googlebot" content="index,follow" />
|
|
||||||
<link rel="manifest" href="{{ .Site.BaseURL }}manifest.json" />
|
|
||||||
<meta name="theme-color" content="#ffffff" />
|
<meta name="theme-color" content="#ffffff" />
|
||||||
<meta name="msapplication-TileColor" content="#ffffff" />
|
<meta name="msapplication-TileColor" content="#ffffff" />
|
||||||
<meta name="imagemode" content="force" />
|
<link rel="sitemap" type="application/xml" title="Sitemap" href="{{ .Site.BaseURL }}sitemap.xml" />
|
||||||
<meta name="coverage" content="Worldwide" />
|
{{ with .OutputFormats.Get "RSS" -}}
|
||||||
<meta name="distribution" content="Global" />
|
<link href="{{ .Permalink }}" rel="feed alternate" type="application/rss+xml" title="{{ $.Site.Title }}" />
|
||||||
<meta name="HandheldFriendly" content="True" />
|
{{- end }}
|
||||||
<meta name="msapplication-tap-highlight" content="no" />
|
<meta name="robots" content="index,follow" />
|
||||||
<meta name="apple-mobile-web-app-title" content="{{ .Site.Title }}" />
|
<meta name="googlebot" content="index,follow" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
||||||
<meta name="apple-touch-fullscreen" content="yes" />
|
|
||||||
|
|
Loading…
Reference in a new issue