mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-11-17 13:25:57 -06:00
Rewrite meta tag partials
This commit is contained in:
parent
b83e20274f
commit
7a0757cef7
@ -20,10 +20,6 @@
|
||||
<link rel="icon" type="image/png" href="{{ . | absURL }}" />
|
||||
{{ end }}
|
||||
|
||||
{{ range .AlternativeOutputFormats -}}
|
||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
||||
{{ end -}}
|
||||
|
||||
{{ if .IsHome }}
|
||||
<title>{{ .Site.Title }}</title>
|
||||
{{ else }}
|
||||
@ -33,8 +29,9 @@
|
||||
{{ partial "opengraph.html" . }}
|
||||
{{ partial "twitter_cards.html" . }}
|
||||
{{ partial "schema.html" . }}
|
||||
|
||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||
|
||||
{{ partial "link_tags.html" . }}
|
||||
{{ partial "author-metadata.html" . }}
|
||||
|
||||
<meta name="language" content="{{ .Language.Lang }}">
|
||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||
</head>
|
||||
|
15
layouts/partials/link_tags.html
Normal file
15
layouts/partials/link_tags.html
Normal file
@ -0,0 +1,15 @@
|
||||
{{ range .AlternativeOutputFormats }}
|
||||
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink }}" title="{{ $.Site.Title }}">
|
||||
{{ end }}
|
||||
{{ with .OutputFormats.Get "rss" }}
|
||||
<link rel="start" type="{{ .MediaType.Type }}" href="{{ .Permalink }}" title="{{ $.Site.Title }}">
|
||||
{{ end }}
|
||||
|
||||
{{ with .PrevInSection }}
|
||||
<link rel="prev" title="{{ .Title }}" href="{{ .Permalink }}">
|
||||
{{ end }}
|
||||
{{ with .NextInSection }}
|
||||
<link rel="next" title="{{ .Title }}" href="{{ .Permalink }}">
|
||||
{{ end }}
|
||||
|
||||
<link rel="canonical" href="{{ .Permalink }}">
|
@ -1,53 +1,48 @@
|
||||
<!-- See https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/opengraph.html -->
|
||||
<meta property="og:title" content="{{ .Title }}" />
|
||||
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
|
||||
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
||||
<meta property="og:url" content="{{ .Permalink }}" />
|
||||
<meta property="og:title" content="{{ .Title }}">
|
||||
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ if .IsPage}}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
|
||||
<meta property="og:url" content="{{ .Permalink }}">
|
||||
|
||||
{{- with $.Params.images -}}
|
||||
{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
|
||||
{{- else -}}
|
||||
{{- $images := $.Resources.ByType "image" -}}
|
||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
||||
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||
{{- with $featured -}}
|
||||
<meta property="og:image" content="{{ $featured.Permalink }}"/>
|
||||
{{- else -}}
|
||||
{{- with $.Site.Params.images }}<meta property="og:image" content="{{ index . 0 | absURL }}"/>{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ $images := $.Resources.ByType "image" }}
|
||||
{{ $featured := $images.GetMatch "*feature*" }}
|
||||
{{ if not $featured }}
|
||||
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
|
||||
{{ end }}
|
||||
|
||||
{{- if .IsPage }}
|
||||
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
||||
<meta property="article:section" content="{{ .Section }}" />
|
||||
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||
{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||
{{- end -}}
|
||||
{{ with $featured }}
|
||||
<meta property="og:image" content="{{ $featured.Permalink }}">
|
||||
{{ end }}
|
||||
|
||||
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
|
||||
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
|
||||
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
|
||||
{{ with .Section }}
|
||||
<meta property="article:section" content="{{ . }}">
|
||||
{{ end }}
|
||||
|
||||
{{- with .Params.videos -}}
|
||||
{{- range first 6 . }}<meta property="og:video" content="{{ . | absURL }}" />{{ end -}}
|
||||
{{- else -}}
|
||||
{{- $videos := $.Resources.ByType "video" -}}
|
||||
{{- $featured_video := $videos.GetMatch "*feature*" -}}
|
||||
{{- if not $featured_video }}{{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||
{{- with $featured_video -}}
|
||||
<meta property="og:video" content="{{ $featured_video.Permalink | absURL }}" />
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ $format := "2006-01-02T15:04:05-07:00" }}
|
||||
{{ with .Date }}
|
||||
<meta property="article:published_time" content="{{ .Format $format }}">
|
||||
{{ end }}
|
||||
{{ with .Lastmod }}
|
||||
<meta property="article:modified_time" {{ .Format $format | printf "content=%q" | safeHTMLAttr }}>
|
||||
{{ end }}
|
||||
|
||||
{{- /* If it is part of a series, link to related articles */}}
|
||||
{{- $permalink := .Permalink }}
|
||||
{{- $siteSeries := .Site.Taxonomies.series }}
|
||||
{{ with .Params.series }}{{- range $name := . }}
|
||||
{{- $series := index $siteSeries ($name | urlize) }}
|
||||
{{- range $page := first 6 $series.Pages }}
|
||||
{{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
|
||||
{{- end }}
|
||||
{{ end }}{{ end }}
|
||||
{{ with .Params.audio }}
|
||||
<meta property="og:audio" content="{{ . }}">
|
||||
{{ end }}
|
||||
|
||||
{{- /* Facebook Page Admin ID for Domain Insights */}}
|
||||
{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
|
||||
{{ with .Language.Lang }}
|
||||
<meta property="og:locale" content="{{ . }}">
|
||||
{{ end }}
|
||||
|
||||
{{ with .Site.Params.title }}
|
||||
<meta property="og:site_name" content="{{ . }}">
|
||||
{{ end }}
|
||||
|
||||
{{ $videos := $.Resources.ByType "video" }}
|
||||
{{ $featured_video := $videos.GetMatch "*feature*" }}
|
||||
{{ if not $featured_video }}
|
||||
{{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }}
|
||||
{{ end }}
|
||||
|
||||
{{ with $featured_video }}
|
||||
<meta property="og:video" content="{{ $featured_video.Permalink | absURL }}">
|
||||
{{ end }}
|
||||
|
@ -1,26 +1,26 @@
|
||||
<!-- See https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/schema.html -->
|
||||
<meta itemprop="name" content="{{ .Title }}">
|
||||
<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||
<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{ if .IsPage }}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||
|
||||
{{ $format := "2006-01-02T15:04:05-07:00" }}
|
||||
{{ with .Date }}
|
||||
<meta itemprop="datePublished" content="{{ .Format $format }}">
|
||||
{{ end }}
|
||||
{{ with .Lastmod }}
|
||||
<meta itemprop="dateModified" content="{{ .Format $format }}">
|
||||
{{ end }}
|
||||
|
||||
{{- if .IsPage -}}
|
||||
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
||||
{{ with .PublishDate }}<meta itemprop="datePublished" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end}}
|
||||
{{ with .Lastmod }}<meta itemprop="dateModified" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end}}
|
||||
<meta itemprop="wordCount" content="{{ .WordCount }}">
|
||||
|
||||
{{- with $.Params.images -}}
|
||||
{{- range first 6 . -}}<meta itemprop="image" content="{{ . | absURL }}">{{ end -}}
|
||||
{{- else -}}
|
||||
{{- $images := $.Resources.ByType "image" -}}
|
||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
||||
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||
{{- with $featured -}}
|
||||
<meta itemprop="image" content="{{ $featured.Permalink }}">
|
||||
{{- else -}}
|
||||
{{- with $.Site.Params.images -}}<meta itemprop="image" content="{{ index . 0 | absURL }}"/>{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ $images := $.Resources.ByType "image" }}
|
||||
{{ $featured := $images.GetMatch "*feature*" }}
|
||||
{{ if not $featured }}
|
||||
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
|
||||
{{ end }}
|
||||
|
||||
<!-- Output all taxonomies as schema.org keywords -->
|
||||
<meta itemprop="keywords" content="{{ if .IsPage}}{{ range $index, $tag := .Params.tags }}{{ $tag }},{{ end }}{{ else }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}" />
|
||||
{{- end -}}
|
||||
{{ with $featured }}
|
||||
<meta itemprop="image" content="{{ $featured.Permalink }}">
|
||||
{{ end }}
|
||||
|
||||
{{ with .Params.tags }}
|
||||
<meta itemprop="keywords" content="{{ delimit . ", " }}">
|
||||
{{ end }}
|
||||
|
@ -1,25 +1,17 @@
|
||||
<!-- See https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/twitter_cards.html -->
|
||||
{{- with $.Params.images -}}
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
|
||||
{{ else -}}
|
||||
{{- $images := $.Resources.ByType "image" -}}
|
||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
||||
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
||||
{{- with $featured -}}
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:image" content="{{ $featured.Permalink }}"/>
|
||||
{{- else -}}
|
||||
{{- with $.Site.Params.images -}}
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
|
||||
{{ else -}}
|
||||
<meta name="twitter:card" content="summary"/>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
<meta name="twitter:title" content="{{ .Title }}"/>
|
||||
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
|
||||
{{ with .Site.Social.twitter -}}
|
||||
<meta name="twitter:site" content="@{{ . }}"/>
|
||||
{{ end -}}
|
||||
{{ $images := $.Resources.ByType "image" }}
|
||||
{{ $featured := $images.GetMatch "*feature*" }}
|
||||
{{ if not $featured }}
|
||||
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
|
||||
{{ end }}
|
||||
|
||||
{{ with $featured }}
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:image" content="{{ $featured.Permalink }}">
|
||||
{{ end }}
|
||||
|
||||
<meta name="twitter:title" content="{{ .Title }}">
|
||||
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{ if .IsPage }}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||
|
||||
{{ with .Site.Social.twitter }}
|
||||
<meta name="twitter:site" content="@{{ . }}">
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user