-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathseo.templ
53 lines (49 loc) · 1.67 KB
/
seo.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package website
import (
"time"
)
type PageInfo struct {
RequestURI string
Title string
Description string
Image string
ImageAlt string
Post *Post
}
templ seo(info PageInfo) {
<title>{ info.Title }</title>
<meta name="description" content={ info.Description }/>
<link rel="canonical" href={ siteURL + info.RequestURI }/>
// Open Graph.
<meta property="og:title" content={ info.Title }/>
<meta property="og:description" content={ info.Description }/>
<meta property="og:url" content={ siteURL + info.RequestURI }/>
if info.Post == nil {
<meta property="og:type" content="website"/>
} else {
<meta property="og:type" content="article"/>
for _, author := range info.Post.Authors {
<meta property="article:author" content={ author.URL() }/>
}
for tag := range info.Post.Tags {
<meta property="article:tag" content={ tag }/>
}
<meta property="article:published_time" content={ info.Post.Date.Format(time.RFC3339) }/>
}
<meta property="og:image" content={ info.Image }/>
<meta property="og:image:alt" content={ info.ImageAlt }/>
<meta property="og:locale" content="en_GB"/>
<meta property="og:site_name" content="Verifa"/>
// Schema Org.
// TODO: fix this:
// https://github.com/a-h/templ/issues/292#issuecomment-1805367649
@SchemaOrgLDJSON()
// Twitter.
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:site" content="@verifa_io"/>
<meta name="twitter:creator" content="@verifa_io"/>
<meta name="twitter:title" content={ info.Title }/>
<meta name="twitter:description" content={ info.Description }/>
<meta name="twitter:image" content={ info.Image }/>
<meta name="twitter:image:alt" content={ info.ImageAlt }/>
}