Skip to content

Commit 62b97d5

Browse files
committed
Test updated opengraph tags
1 parent 4772922 commit 62b97d5

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{{ if or (eq site.BaseURL "/") (eq site.BaseURL "http://localhost:1313/") }}
2+
{{ else }}
3+
<base href="{{ .Permalink }}" />
4+
{{ end }}
5+
6+
{{ $title := site.Title }}
7+
{{ if .Params.meta_title }}
8+
{{ $title = .Params.meta_title }}
9+
{{ else if .Params.title }}
10+
{{ $title = .Params.title }}
11+
{{ end }}
12+
13+
<title>{{ $title }}</title>
14+
15+
{{ if .Params.noindex }}
16+
<meta name="robots" content="noindex,nofollow" />
17+
{{ end }}
18+
19+
{{ with .Params.canonical }}
20+
<link rel="canonical" href="{{ . }}" itemprop="url" />
21+
{{ end }}
22+
23+
{{ if .IsTranslated }}
24+
{{ range .AllTranslations }}
25+
<link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}" />
26+
{{ end }}
27+
<link rel="alternate" hreflang="x-default" href="{{ .Permalink }}" />
28+
{{ end }}
29+
30+
{{ if .Params.keywords }}
31+
<meta name="keywords" content="{{ delimit .Params.keywords `, ` }}" />
32+
{{ else if site.Params.metadata.keywords }}
33+
<meta name="keywords" content="{{ delimit site.Params.metadata.keywords `, ` }}" />
34+
{{ end }}
35+
36+
<meta name="description" content="{{ .Params.description | default site.Params.metadata.description }}" />
37+
38+
{{ with site.Params.metadata.author }}
39+
<meta name="author" content="{{ . }}" />
40+
{{ end }}
41+
42+
<meta property="og:type" content="website" />
43+
<meta property="og:url" content="{{ .Permalink }}" />
44+
<meta property="og:title" content="{{ if .Params.og_title }}{{ .Params.og_title }}{{ else }}Open Neuromorphic{{ end }}" />
45+
<meta property="og:description" content="{{ if .Params.og_description }}{{ .Params.og_description }}{{ else }}Explore the world of Neuromorphic Computing, AI, and Devices in an open-source community. Join us for educational content, and collaborative innovation{{ end }}" />
46+
<meta property="og:image" content="{{ if .Params.og_image }}{{ .Params.og_image }}{{ else }}https://open-neuromorphic.org/images/og-image.png{{ end }}" />
47+
48+
<meta name="twitter:card" content="summary_large_image" />
49+
<meta property="twitter:domain" content="open-neuromorphic.org" />
50+
<meta property="twitter:url" content="{{ .Permalink }}" />
51+
<meta name="twitter:title" content="{{ if .Params.twitter_title }}{{ .Params.twitter_title }}{{ else }}Open Neuromorphic{{ end }}" />
52+
<meta name="twitter:description" content="{{ if .Params.twitter_description }}{{ .Params.twitter_description }}{{ else }}Explore the world of Neuromorphic Computing, AI, and Devices in an open-source community. Join us for educational content, and collaborative innovation{{ end }}" />
53+
<meta name="twitter:image" content="{{ if .Params.twitter_image }}{{ .Params.twitter_image }}{{ else }}https://open-neuromorphic.org/images/og-image.png{{ end }}" />
54+
55+
{{ $imagePath := site.Params.metadata.image }}
56+
{{ if .Params.meta_image }}
57+
{{ $imagePath = .Params.meta_image }}
58+
{{ else if .Params.images }}
59+
{{ range first 1 .Params.images }}
60+
{{ $imagePath = . }}
61+
{{ end }}
62+
{{ else if .Params.image }}
63+
{{ $imagePath = .Params.image }}
64+
{{ end }}
65+
66+
{{ if or (hasPrefix $imagePath "http") (fileExists (add `static/` (string $imagePath))) }}
67+
<meta name="twitter:image" content="{{ $imagePath | absURL }}" />
68+
<meta property="og:image" content="{{ $imagePath | absURL }}" />
69+
{{ else }}
70+
{{ $contentImage:= .Resources.GetMatch (printf "*%s*" $imagePath) }}
71+
{{ $assetImage:= fileExists (add `assets/` (string $imagePath)) }}
72+
73+
{{ if or $contentImage $assetImage }}
74+
{{ if $contentImage }}
75+
{{ .Scratch.Set "image-exists" $contentImage }}
76+
{{ else if $assetImage }}
77+
{{ .Scratch.Set "image-exists" (resources.Get $imagePath) }}
78+
{{ end }}
79+
80+
{{ $image:= .Scratch.Get "image-exists" }}
81+
82+
{{ $imageExt:= path.Ext $image }}
83+
84+
{{ if ne $imageExt `.svg` }}
85+
{{ $imageWidth := $image.Width }}
86+
{{ $imageHeight := $image.Height }}
87+
{{ if (and (gt $imageWidth 144) (gt $imageHeight 144)) }}
88+
<meta property="og:image" content="{{ $image.Permalink }}" />
89+
<meta name="twitter:image" content="{{ $image.Permalink }}" />
90+
<meta name="twitter:card" content="{{- if (and (gt $imageWidth 300) (gt $imageHeight 157) (not (eq $imageWidth $imageHeight))) -}}summary_large_image{{- else -}}summary{{- end -}}" />
91+
{{ end }}
92+
<meta property="og:image:width" content="{{ $imageWidth }}" />
93+
<meta property="og:image:height" content="{{ $imageHeight }}" />
94+
{{ end }}
95+
96+
<meta property="og:image:type" content="image/{{- if eq $imageExt `.svg` -}} svg+xml {{- else -}} {{ replaceRE `^jpg$` `jpeg` $imageExt }} {{- end -}}" />
97+
{{ end }}
98+
{{ end }}
99+
<meta property="og:description" content="{{ if .Params.og_description }}{{ .Params.og_description }}{{ else }}Explore the world of Neuromorphic Computing, AI, and Devices in an open-source community. Join us for educational content, and collaborative innovation{{ end }}" />
100+
101+
<meta name="twitter:description" content="{{ if .Params.twitter_description }}{{ .Params.twitter_description }}{{ else }}Explore the world of Neuromorphic Computing, AI, and Devices in an open-source community. Join us for educational content, and collaborative innovation{{ end }}" />
102+
103+
{{ with site.Params.metadata.twitter }}
104+
<meta name="twitter:site" content="@{{ . }}" />
105+
{{ end }}
106+
{{ with site.Params.metadata.author }}
107+
<meta name="twitter:creator" content="@{{ . }}" />
108+
{{ end }}

themes/hugoplate/layouts/partials/essentials/head.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
<!-- opengraph and twitter card -->
39-
{{ partial "basic-seo.html" . }}
39+
{{ partial "components/base-seo.html" . }}
4040

4141

4242
<!-- custom script -->

0 commit comments

Comments
 (0)