Skip to content

Commit 8adc4ca

Browse files
authored
feat: initial attempt at meta tags leveraging frontmatter description (#23)
1 parent 04872a2 commit 8adc4ca

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

layouts/partials/head.html

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
<meta charset="utf-8"/>
22
<meta name="viewport" content="width=device-width initial-scale=1.0"/>
33
{{- if .IsHome -}}
4-
<title>{{- site.Title | emojify }}</title>
5-
{{ else -}}
6-
<title>{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}</title>
7-
<meta name="title" content="{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}"/>
8-
{{ end -}}
4+
<title>{{- site.Title | emojify }}</title>
5+
{{- else -}}
6+
<title>{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}</title>
7+
<meta name="title" content="{{ .Title | emojify }} &middot; {{ .Site.Title | emojify }}"/>
8+
{{- end -}}
99
<!-- Metadata -->
10-
{{- with .Params.Description -}}
11-
<meta name="description" content="{{ . }}"/>
12-
{{ else -}}
13-
<meta name="description" content="{{ $.Site.Params.Description }}"/>
14-
{{ end -}}
15-
{{ with .Site.Params.keywords -}}
16-
<meta name="keywords" content="{{ . }}"/>
17-
{{ end -}}
18-
{{ with .Site.Params.robots -}}
19-
<meta name="robots" content="{{ . }}"/>
20-
{{ end -}}
21-
{{ with .Params.robots -}}
22-
<meta name="robots" content="{{ . }}"/>
10+
{{- if .Description -}}
11+
<meta name="description" content="{{ .Description }}"/>
12+
{{- else -}}
13+
<meta name="description" content="{{ $.Site.Params.Description }}"/>
14+
{{- end -}}
15+
{{- if .Keywords -}}
16+
<meta name="keywords" content="{{ . }}"/>
17+
{{- else -}}
18+
{{- with .Site.Params.keywords -}}
19+
<meta name="keywords" content="{{ . }}"/>
20+
{{- end -}}{{- end -}}
21+
{{- with .Site.Params.robots -}}
22+
<meta name="robots" content="{{ . }}"/>
23+
{{- end -}}
24+
{{- with .Params.robots -}}
25+
<meta name="robots" content="{{ . }}"/>
2326
{{ end -}}
2427
<link rel="canonical" href="{{ .Permalink | absURL }}"/>
2528
{{- range .AlternativeOutputFormats }}
26-
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink $.Site.Title | emojify | safeHTML -}}
29+
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink $.Site.Title | emojify | safeHTML -}}
2730
{{- end -}}
2831
{{ partialCached "head/css.html" . -}}
2932
{{- partialCached "fonts.html" . -}}
@@ -34,7 +37,7 @@
3437
<link rel="manifest" href="/site.webmanifest"/>
3538
<!-- https://gohugo.io/templates/rss/#include-feed-reference -->
3639
{{- with .OutputFormats.Get "rss" }}
37-
{{- printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML -}}
40+
{{- printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML -}}
3841
{{- end -}}
3942
<!-- Add your custom headers here -->
4043
{{- partial "head-custom.html" . -}}

0 commit comments

Comments
 (0)