Source code of my website
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

๐Ÿ’„ : use cover images for open graph images

+156
+156
layouts/partials/head/meta.html
··· 1 + {{ .Scratch.Set "title" .Site.Title }} 2 + 3 + {{ .Scratch.Set "publisherIcon" .Site.Params.favicon }} 4 + {{ if .Site.Params.publisherIcon }} 5 + {{ .Scratch.Set "publisherIcon" .Site.Params.publisher_icon }} 6 + {{ end }} 7 + 8 + {{ if eq .Kind "home" }} 9 + {{ .Scratch.Set "title" $.Site.Params.brand }} 10 + {{ .Scratch.Set "description" .Site.Params.Description }} 11 + {{ else }} 12 + {{ .Scratch.Set "description" .Description }} 13 + {{ end }} 14 + 15 + {{ if .IsSection }} 16 + {{ .Scratch.Set "title" ($.Site.Params.brand) }} 17 + {{ .Scratch.Add "title" " - " }} 18 + {{ .Scratch.Add "title" .LinkTitle }} 19 + {{ end }} 20 + 21 + {{ if .IsPage }} 22 + {{ .Scratch.Set "title" ($.Site.Params.brand) }} 23 + {{ .Scratch.Add "title" " - " }} 24 + {{ .Scratch.Add "title" .LinkTitle }} 25 + {{ end }} 26 + 27 + {{ with .Resources }} 28 + {{ with .GetMatch "{cover.*}" }} 29 + {{ $cover := .Resize "820x" }} 30 + {{ with $cover }} 31 + {{ "<!-- Open Graph image and Twitter Card metadata -->" | safeHTML }} 32 + {{ $image_ext := trim (path.Ext $cover | lower) "." -}} 33 + <meta property="og:image" content="{{ $cover.RelPermalink }}" /> 34 + {{/* If not SVG, read image aspect ratio and define Twitter Card and Open Graph width and height */ -}} 35 + {{ if ne $image_ext "svg" -}} 36 + {{ if (and (gt $cover.Width 144) (gt $cover.Height 144)) -}} 37 + <meta name="twitter:image" content="{{ $cover.RelPermalink }}"/> 38 + <meta name="twitter:card" content="summary{{ if (and (gt .Width 300) (gt .Height 157) (not (eq .Width .Height))) }}_large_image{{ end }}"> 39 + {{ end -}} 40 + <meta property="og:image:width" content="{{ .Width }}"> 41 + <meta property="og:image:height" content="{{ .Height }}"> 42 + {{ end -}} 43 + <meta property="og:image:type" content="image/{{ if eq $image_ext `svg` }}svg+xml{{ else }}{{ replaceRE `^jpg$` `jpeg` $image_ext }}{{ end }}"> 44 + {{ end }} 45 + {{ end }} 46 + {{ else }} 47 + {{ if eq page.Kind "post" }} 48 + {{ warnf "no cover for page %s" page.Title }} 49 + {{ end }} 50 + {{ "<!-- Open Graph image and Twitter Card metadata -->" | safeHTML }} 51 + {{ $image_path := site.Params.og_image -}} 52 + {{ with $image_path }} 53 + {{ $image_path_local := printf "assets/%s" $image_path -}} 54 + {{ $image_ext := trim (path.Ext $image_path | lower) "." -}} 55 + {{ if fileExists $image_path_local -}} 56 + {{ $image_path:= resources.Get $image_path}} 57 + <meta property="og:image" content="{{ $image_path.RelPermalink }}" /> 58 + {{/* If not SVG, read image aspect ratio and define Twitter Card and Open Graph width and height */ -}} 59 + {{ if ne $image_ext "svg" -}} 60 + {{ with (imageConfig $image_path_local) -}} 61 + {{ if (and (gt .Width 144) (gt .Height 144)) -}} 62 + <meta name="twitter:image" content="{{ $image_path.RelPermalink }}"/> 63 + <meta name="twitter:card" content="summary{{ if (and (gt .Width 300) (gt .Height 157) (not (eq .Width .Height))) }}_large_image{{ end }}"> 64 + {{ end -}} 65 + <meta property="og:image:width" content="{{ .Width }}"> 66 + <meta property="og:image:height" content="{{ .Height }}"> 67 + {{ end -}} 68 + {{ end -}} 69 + <meta property="og:image:type" content="image/{{ if eq $image_ext `svg` }}svg+xml{{ else }}{{ replaceRE `^jpg$` `jpeg` $image_ext }}{{ end }}"> 70 + {{ end -}} 71 + {{ end -}} 72 + {{ end }} 73 + 74 + <!-- Title Tags --> 75 + <title itemprop="name">{{ .Scratch.Get "title" }}</title> 76 + <meta property="og:title" content={{ .Scratch.Get "title" }} /> 77 + <meta name="twitter:title" content={{ .Scratch.Get "title" }} /> 78 + <meta itemprop="name" content={{ .Scratch.Get "title" }} /> 79 + <meta name="application-name" content={{ .Scratch.Get "title" }} /> 80 + <meta property="og:site_name" content="{{ .Site.Title }}" /> 81 + 82 + <!-- Description Tags --> 83 + <meta name="description" content="{{ .Scratch.Get "description" }}" /> 84 + <meta itemprop="description" content="{{ .Scratch.Get "description" }}" /> 85 + <meta property="og:description" content="{{ .Scratch.Get "description" }}" /> 86 + <meta name="twitter:description" content="{{ .Scratch.Get "description" }}" /> 87 + 88 + <!-- Link Tags --> 89 + <base href="{{ .Permalink }}" /> 90 + <link rel="canonical" href="{{ .Permalink }}" itemprop="url" /> 91 + <meta name="url" content="{{ .Permalink }}" /> 92 + <meta name="twitter:url" content="{{ .Permalink }}" /> 93 + <meta property="og:url" content="{{ .Permalink }}" /> 94 + 95 + <!-- Date Tags --> 96 + <meta property="og:updated_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}" /> 97 + 98 + <!-- Sitemap & Alternate Outputs --> 99 + <link rel="sitemap" type="application/xml" title="Sitemap" href='{{ "sitemap.xml" | absURL }}' /> 100 + {{ range .AlternativeOutputFormats -}} 101 + {{ printf `<link href="%s" rel="%s" type="%s" title="%s" />` .Permalink .Rel .MediaType.Type $.Site.Title | safeHTML }} 102 + {{ end -}} 103 + 104 + <!-- Search Engine Crawler Tags --> 105 + <meta name="robots" content="index,follow" /> 106 + <meta name="googlebot" content="index,follow" /> 107 + 108 + <!-- Social Media Tags --> 109 + {{if (or (ne .Site.Params.twitter_url nil) (ne .Site.Params.x_url nil))}} 110 + {{ $twitter_user := index (split (default .Site.Params.twitter_url .Site.Params.x_url) "/") 3 }} 111 + <meta name="twitter:site" content="@{{ $twitter_user }}" /> 112 + <meta name="twitter:creator" content="@{{ $twitter_user }}" /> 113 + {{end}} 114 + <meta property="fb:admins" content="{{ .Site.Params.fb.admins }}" /> 115 + 116 + <!-- Other Tags --> 117 + <meta name="apple-mobile-web-app-title" content="{{ .Site.Title }}" /> 118 + <meta name="apple-mobile-web-app-capable" content="yes" /> 119 + <meta name="apple-mobile-web-app-status-bar-style" content="black" /> 120 + 121 + <!-- Article Specific Tags --> 122 + <!-- To make sure this renders only in the article page, we check the section --> 123 + {{ if and (eq .Section "posts") (.Page.IsNode) }} 124 + <!-- Pagination meta tags for list pages only --> 125 + {{ $paginator := .Paginate (where .Pages "Type" "posts") }} 126 + {{ if $paginator }} 127 + <link rel="first" href="{{ $paginator.First.URL }}" /> 128 + <link rel="last" href="{{ $paginator.Last.URL }}" /> 129 + {{ if $paginator.HasPrev }} 130 + <link rel="prev" href="{{ $paginator.Prev.URL }}" /> 131 + {{end }} 132 + {{ if $paginator.HasNext }} 133 + <link rel="next" href="{{ $paginator.Next.URL }}" /> 134 + {{end }} 135 + {{end }} 136 + 137 + <meta property="og:type" content="article" /> 138 + <meta property="article:publisher" content="{{ .Site.Params.facebook_url }}" /> 139 + <meta property="og:article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}" /> 140 + <meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}" /> 141 + 142 + {{ with (or (.Params.Author) (.Site.Language.Params.Author.Name)) }} 143 + <meta property="og:article:author" content="{{ . }}" /> 144 + <meta property="article:author" content="{{ . }}" /> 145 + <meta name="author" content="{{ . }}" /> 146 + {{ end }} 147 + 148 + {{ with.Params.category }} 149 + <meta name="news_keywords" content="{{ index . 0 }}" /> 150 + <meta property="article:section" content="{{ index . 0 }}" /> 151 + {{ end }} 152 + 153 + {{ end }} 154 + 155 + <!-- Hugo Generator Attribution --> 156 + {{ hugo.Generator }}