Skip to content

Commit

Permalink
Add OpenGraph Headers (hugo-toha#333)
Browse files Browse the repository at this point in the history
Signed-off-by: hossainemruz <[email protected]>
  • Loading branch information
hossainemruz committed May 30, 2021
1 parent d9df105 commit 4a0aa47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>{{ .Page.Title }}</title>
<!------ ADD COMMON HEADERS -------->
{{- partial "header.html" . -}}
{{ template "_internal/opengraph.html" . }}

<!------ ADD PAGE SPECIFIC HEADERS ------->
{{ block "header" . }} {{ end }}
Expand Down
1 change: 1 addition & 0 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<!-- import common headers -->
{{- partial "header.html" . -}}
{{- partial "opengraph.html" . -}}

<!-- import index page specific headers -->
<link rel="stylesheet" href="{{ "/css/sections/home.css" | relURL }}"/>
Expand Down
12 changes: 12 additions & 0 deletions layouts/partials/opengraph.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ $title := (index site.Data site.Language.Lang).site.openGraph.title | default site.Title }}
{{ $type := (index site.Data site.Language.Lang).site.openGraph.type | default "website" }}
{{ $description := (index site.Data site.Language.Lang).site.openGraph.description | default (index site.Data site.Language.Lang).site.description }}
{{ $image := (index site.Data site.Language.Lang).site.openGraph.image | default (index site.Data site.Language.Lang).author.image }}
{{ $url := (index site.Data site.Language.Lang).site.openGraph.url | default site.BaseURL }}

<!-- ============ open graph tags ========== -->
<meta property="og:title" content="{{ $title }}"/>
<meta property="og:type" content="{{ $type }}"/>
<meta property="og:description" content="{{ $description }}"/>
<meta property="og:image" content="{{ $image }}">
<meta property="og:url" content="{{ $url }}">

0 comments on commit 4a0aa47

Please sign in to comment.