Browse Source

add preview images

max.mehl 1 month ago
parent
commit
62f446b296
No account linked to committer's email address
1 changed files with 32 additions and 10 deletions
  1. 32
    10
      themes/hugo-sustain/layouts/partials/head.html

+ 32
- 10
themes/hugo-sustain/layouts/partials/head.html View File

@@ -1,29 +1,51 @@
1 1
 <!DOCTYPE html>
2 2
 <html lang="{{ .Site.LanguageCode }}">
3 3
   <head>
4
+    <!-- set variables -->
5
+    {{- $title := "" -}}
6
+    {{- if .IsHome -}}
7
+        {{- $title = .Site.Title -}}
8
+    {{- else -}}
9
+        {{- if .Params.heading -}}
10
+          {{- $title = .Params.heading -}}
11
+        {{- else -}}
12
+          {{- $title = print .Site.Title " | " .Title -}}
13
+        {{- end -}}
14
+    {{- end -}}
15
+    {{- $image := "/img/profile.jpg" -}}
16
+    {{- if isset .Params "headerimage" }} {{ $image = .Params.headerimage }} {{ end -}}
4 17
     <meta charset="utf-8" />
5 18
     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6 19
     <meta name="viewport" content="width=device-width, initial-scale=1" />
7 20
     <meta name="author" content="{{ .Site.Params.Author }}" />
8 21
     {{ with .Site.Params.description }}<meta name="description" content="{{ . }}" />{{ end }}
9
-    {{ with .Site.Params.keywords }}<meta name="description" content="{{ . }}" />{{ end }}
22
+    {{ with .Site.Params.keywords }}<meta name="keywords" content="{{ . }}" />{{ end }}
10 23
     <link rel="shortcut icon" type="image/x-icon" href="{{ .Site.BaseURL }}img/favicon.ico" />
11 24
     <link href="/blog/index.xml" rel="alternate" type="application/rss+xml" title="Max Mehl - blog feed">
12 25
     <link href="/categories/english/index.xml" rel="alternate" type="application/rss+xml" title="Max Mehl - blog feed (EN)">
13 26
     <link href="/categories/deutsch/index.xml" rel="alternate" type="application/rss+xml" title="Max Mehl - blog feed (DE)">
14
-    <title>
15
-      {{- if .IsHome -}}
16
-          {{- .Site.Title -}}
17
-      {{- else -}}
18
-          {{- if .Params.heading -}} {{- .Params.heading -}} {{- else -}} {{- .Site.Title -}} {{ print " | " }} {{- .Title -}} {{- end -}}
19
-      {{- end -}}
20
-    </title>
27
+    <title>{{ $title }}</title>
21 28
     <link rel="stylesheet" type="text/css" href="{{ .Site.BaseURL }}css/bootstrap-3.3.7.min.css" />
22 29
     <link rel="stylesheet" type="text/css" href="{{ .Site.BaseURL }}css/main.css" />
23 30
     <link rel="stylesheet" type="text/css" href="{{ .Site.BaseURL }}css/luxbar.css" />
24 31
     <link rel="stylesheet" type="text/css" href="{{ .Site.BaseURL }}css/fontawesome/css/all.min.css" />
25 32
     <link rel="stylesheet" type="text/css" href="{{ .Site.BaseURL }}css/fonts.css" />
26
-    {{ range .Site.Params.custom_css }}
33
+    {{- range .Site.Params.custom_css }}
27 34
     <link rel="stylesheet" href="{{ $.Site.BaseURL}}{{ . }}?v={{ md5 hugo.BuildDate }}" />
28
-    {{ end }}
35
+    {{- end }}
36
+
37
+    {{ "<!-- Open Graph meta-data (e.g. Facebook) -->" | safeHTML }}
38
+    <meta property="og:title" content="{{ $title }}"/>
39
+    <meta property="og:url" content="{{ .Permalink | absURL }}"/>
40
+    <meta property="og:image" content="{{ $image  | absURL }}"/>
41
+    <meta property="og:description" content="{{ .Summary | truncate 200 }}"/>
42
+
43
+    {{ "<!-- Twitter meta-data -->" | safeHTML }}
44
+    <meta name="twitter:card" content="summary_large_image"/>
45
+    <meta name="twitter:site" content="@{{ .Site.Params.social.twitter }}"/>
46
+    <meta name="twitter:title" content="{{ $title }}"/>
47
+    <meta name="twitter:description" content="{{ .Summary | truncate 200 }}"/>
48
+    <meta name="twitter:image" content="{{ $image  | absURL }}"/>
49
+    <meta name="twitter:url" content="{{ .Permalink | absURL }}"/>
50
+    <meta name="twitter:creator" content="@{{ .Site.Params.social.twitter }}"/>
29 51
   </head>

Loading…
Cancel
Save