forked from TrueCloudLab/dot-hugo
added meta OG and Twitter data
This commit is contained in:
parent
e45d6108ea
commit
4685e0da58
2 changed files with 34 additions and 0 deletions
|
@ -22,6 +22,11 @@ logo = ""
|
|||
logo_white = ""
|
||||
# when logo is empty, it will shown your site title
|
||||
|
||||
# OpenGraph / Twitter Card metadata
|
||||
description = "This is meta description"
|
||||
author = "Themefisher"
|
||||
image = "images/logo.png" # this image will be used as fallback if a page has no image of its own
|
||||
|
||||
# customize color
|
||||
primary_color = "#02007e"
|
||||
body_color = "#f9f9f9"
|
||||
|
|
|
@ -57,4 +57,33 @@
|
|||
{{ "<!-- create /layouts/partials/overrides/header.html in your own theme or root directory to add your custom content here -->" | safeHTML }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
<!-- Open Graph image and Twitter Card metadata -->
|
||||
{{ $image_path := .Params.image | default site.Params.image }}
|
||||
{{ $image_path_local := printf "static/%s" $image_path }}
|
||||
{{ $image_ext := trim (path.Ext $image_path | lower) "." }}
|
||||
{{ if fileExists $image_path_local }}
|
||||
<meta property="og:image" content="{{ $image_path | absURL }}" />
|
||||
{{ if ne $image_ext "svg" }}
|
||||
{{ with (imageConfig $image_path_local) }}
|
||||
{{ if (and (gt .Width 144) (gt .Height 144)) }}
|
||||
<meta name="twitter:image" content="{{ $image_path | absURL }}"/>
|
||||
<meta name="twitter:card" content="summary{{ if (and (gt .Width 300) (gt .Height 157) (not (eq .Width .Height))) }}_large_image{{ end }}">
|
||||
{{ end }}
|
||||
<meta property="og:image:width" content="{{ .Width }}">
|
||||
<meta property="og:image:height" content="{{ .Height }}">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<meta property="og:image:type" content="image/{{ if eq $image_ext `svg` }}svg+xml{{ else }}{{ replaceRE `^jpg$` `jpeg` $image_ext }}{{ end }}">
|
||||
{{ end }}
|
||||
<meta name="twitter:title" content="{{ .Title }}"/>
|
||||
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{ if .IsPage }}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"/>
|
||||
{{ with site.Social.twitter }}<meta name="twitter:site" content="@{{ . }}"/>{{ end }}
|
||||
{{ range site.Authors }}
|
||||
{{ with .twitter }}<meta name="twitter:creator" content="@{{ . }}"/>{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ template "_internal/opengraph.html" . }}
|
||||
{{ template "_internal/twitter_cards.html" . }}
|
||||
|
||||
</head>
|
||||
|
|
Loading…
Reference in a new issue