Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tpl: Plainify .Title, .Description and .Summary for meta tags #9856

Closed
wants to merge 8 commits into from
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ with .Description | $.RenderString | plainify -}}
{{ . -}}
{{ else -}}
{{ if .IsPage -}}
{{ .Summary | plainify | chomp -}}
{{ else -}}
{{ with .Site.Params.description | $.RenderString | plainify -}}
{{ . -}}
{{ end -}}
{{ end -}}
{{ end -}}
1 change: 1 addition & 0 deletions tpl/tplimpl/embedded/templates/helpers/plain_title.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- .Title | $.RenderString | plainify -}}
bowman2001 marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions tpl/tplimpl/embedded/templates/opengraph.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<meta property="og:title" content="{{ .Title }}" />
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
<meta property="og:title" content="{{ template "_internal/helpers/plain_title.html" . }}" />
<meta property="og:description" content="{{ template "_internal/helpers/plain_description_or_summary.html" . }}" />
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />

Expand Down
4 changes: 2 additions & 2 deletions tpl/tplimpl/embedded/templates/schema.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<meta itemprop="name" content="{{ .Title }}">
<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
<meta itemprop="name" content="{{ template "_internal/helpers/plain_title.html" . }}">
<meta itemprop="description" content="{{ template "_internal/helpers/plain_description_or_summary.html" . }}">

{{- if .IsPage -}}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
Expand Down
4 changes: 2 additions & 2 deletions tpl/tplimpl/embedded/templates/twitter_cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
{{- end -}}
{{- end -}}
{{- end }}
<meta name="twitter:title" content="{{ .Title }}"/>
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
<meta name="twitter:title" content="{{ template "_internal/helpers/plain_title.html" . }}"/>
<meta name="twitter:description" content="{{ template "_internal/helpers/plain_description_or_summary.html" . }}"/>
{{ with .Site.Social.twitter -}}
<meta name="twitter:site" content="@{{ . }}"/>
{{ end -}}