mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-12-22 12:13:19 -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 }}" />
|
<link rel="icon" type="image/png" href="{{ . | absURL }}" />
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ range .AlternativeOutputFormats -}}
|
|
||||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
|
||||||
{{ end -}}
|
|
||||||
|
|
||||||
{{ if .IsHome }}
|
{{ if .IsHome }}
|
||||||
<title>{{ .Site.Title }}</title>
|
<title>{{ .Site.Title }}</title>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
@ -33,8 +29,9 @@
|
|||||||
{{ partial "opengraph.html" . }}
|
{{ partial "opengraph.html" . }}
|
||||||
{{ partial "twitter_cards.html" . }}
|
{{ partial "twitter_cards.html" . }}
|
||||||
{{ partial "schema.html" . }}
|
{{ partial "schema.html" . }}
|
||||||
|
{{ partial "link_tags.html" . }}
|
||||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
|
||||||
|
|
||||||
{{ partial "author-metadata.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>
|
</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: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: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:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
<meta property="og:url" content="{{ .Permalink }}">
|
||||||
<meta property="og:url" content="{{ .Permalink }}" />
|
|
||||||
|
|
||||||
{{- with $.Params.images -}}
|
{{ $images := $.Resources.ByType "image" }}
|
||||||
{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
|
{{ $featured := $images.GetMatch "*feature*" }}
|
||||||
{{- else -}}
|
{{ if not $featured }}
|
||||||
{{- $images := $.Resources.ByType "image" -}}
|
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
|
||||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
{{ end }}
|
||||||
{{- 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 -}}
|
|
||||||
|
|
||||||
{{- if .IsPage }}
|
{{ with $featured }}
|
||||||
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
<meta property="og:image" content="{{ $featured.Permalink }}">
|
||||||
<meta property="article:section" content="{{ .Section }}" />
|
{{ end }}
|
||||||
{{ 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 .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
|
{{ with .Section }}
|
||||||
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
|
<meta property="article:section" content="{{ . }}">
|
||||||
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{- with .Params.videos -}}
|
{{ $format := "2006-01-02T15:04:05-07:00" }}
|
||||||
{{- range first 6 . }}<meta property="og:video" content="{{ . | absURL }}" />{{ end -}}
|
{{ with .Date }}
|
||||||
{{- else -}}
|
<meta property="article:published_time" content="{{ .Format $format }}">
|
||||||
{{- $videos := $.Resources.ByType "video" -}}
|
{{ end }}
|
||||||
{{- $featured_video := $videos.GetMatch "*feature*" -}}
|
{{ with .Lastmod }}
|
||||||
{{- if not $featured_video }}{{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
<meta property="article:modified_time" {{ .Format $format | printf "content=%q" | safeHTMLAttr }}>
|
||||||
{{- with $featured_video -}}
|
{{ end }}
|
||||||
<meta property="og:video" content="{{ $featured_video.Permalink | absURL }}" />
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- /* If it is part of a series, link to related articles */}}
|
{{ with .Params.audio }}
|
||||||
{{- $permalink := .Permalink }}
|
<meta property="og:audio" content="{{ . }}">
|
||||||
{{- $siteSeries := .Site.Taxonomies.series }}
|
{{ end }}
|
||||||
{{ 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 }}
|
|
||||||
|
|
||||||
{{- /* Facebook Page Admin ID for Domain Insights */}}
|
{{ with .Language.Lang }}
|
||||||
{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
|
<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="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 }}">
|
<meta itemprop="wordCount" content="{{ .WordCount }}">
|
||||||
|
|
||||||
{{- with $.Params.images -}}
|
{{ $images := $.Resources.ByType "image" }}
|
||||||
{{- range first 6 . -}}<meta itemprop="image" content="{{ . | absURL }}">{{ end -}}
|
{{ $featured := $images.GetMatch "*feature*" }}
|
||||||
{{- else -}}
|
{{ if not $featured }}
|
||||||
{{- $images := $.Resources.ByType "image" -}}
|
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
|
||||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
{{ end }}
|
||||||
{{- 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 -}}
|
|
||||||
|
|
||||||
<!-- Output all taxonomies as schema.org keywords -->
|
{{ with $featured }}
|
||||||
<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 }}" />
|
<meta itemprop="image" content="{{ $featured.Permalink }}">
|
||||||
{{- end -}}
|
{{ 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 -->
|
{{ $images := $.Resources.ByType "image" }}
|
||||||
{{- with $.Params.images -}}
|
{{ $featured := $images.GetMatch "*feature*" }}
|
||||||
<meta name="twitter:card" content="summary_large_image"/>
|
{{ if not $featured }}
|
||||||
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
|
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
|
||||||
{{ else -}}
|
{{ end }}
|
||||||
{{- $images := $.Resources.ByType "image" -}}
|
|
||||||
{{- $featured := $images.GetMatch "*feature*" -}}
|
{{ with $featured }}
|
||||||
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
|
<meta name="twitter:card" content="summary">
|
||||||
{{- with $featured -}}
|
<meta name="twitter:image" content="{{ $featured.Permalink }}">
|
||||||
<meta name="twitter:card" content="summary_large_image"/>
|
{{ end }}
|
||||||
<meta name="twitter:image" content="{{ $featured.Permalink }}"/>
|
|
||||||
{{- else -}}
|
<meta name="twitter:title" content="{{ .Title }}">
|
||||||
{{- with $.Site.Params.images -}}
|
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{ if .IsPage }}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
|
||||||
<meta name="twitter:card" content="summary_large_image"/>
|
|
||||||
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
|
{{ with .Site.Social.twitter }}
|
||||||
{{ else -}}
|
<meta name="twitter:site" content="@{{ . }}">
|
||||||
<meta name="twitter:card" content="summary"/>
|
{{ end }}
|
||||||
{{- 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 -}}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user