Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenGraph and TwitterCard metadata #52

Merged
merged 6 commits into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion archetypes/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ date:
description: ""
tags: []
featured_image: ""
# images is optional, but needed for showing Twitter Card
images: []
categories:
comment : true
---
draft: true
---
6 changes: 6 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ theme = "diary"
subtitle = "Themed by Diary."
enableGitalk = true

# Twitter Card and Open Graph settings
enableOpenGraph = true
enableTwitterCards = true
title = "My Blog" # will set 'og:site_name'
description = "My HomePage Description" # will set 'og:description'

[params.gitalk]
owner = "user"
repo = "repo name"
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/chapter-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
date: 2017-04-09T10:58:08-04:00
description: "The Grand Hall"
featured_image: "/images/Pope-Edouard-de-Beaumont-1844.jpg"
images: ["/images/Pope-Edouard-de-Beaumont-1844.jpg"]
tags: ["scene"]
categories: "Story"
title: "Chapter I: The Grand Hall"
Expand Down
22 changes: 21 additions & 1 deletion layouts/partials/head.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
<head>
<title>{{.Title}}</title>

{{ $description := .Params.description}}
{{if .IsHome}}
{{ $description = .Site.Params.description}}
{{end}}

<meta charset="utf-8">
<meta name="X-UA-Compatible" content="IE=edge">
<meta name="google-site-verification" content="{{ .Site.Params.googleSiteVerification }}">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<meta content="telephone=no" name="format-detection">
<meta name="description" content="{{ .Params.description }}">
<meta name="description" content="{{ $description }}">
<meta name="renderer" content="webkit">
<meta name="theme-color" content="#ffffff">

<!-- open-graph -->
{{if .Site.Params.enableOpenGraph}}
{{ template "_internal/opengraph.html" . }}
{{end}}

<!-- twitter-cards -->
{{if .Site.Params.enableTwitterCards}}
{{ template "_internal/twitter_cards.html" . }}
{{end}}

<!-- metadata -->

{{ if .Site.GoogleAnalytics }}
Expand All @@ -22,6 +38,10 @@
<link type="text/css" rel="stylesheet" href="{{"/vendor/css/bootstrap.min.css" | relURL}}">
<script src="{{"/vendor/js/vue.min.js" | relURL}}" ></script>

{{if .Site.Params.manifest}}
<link rel="manifest" href="{{.Site.Params.manifest}}">
{{end}}

{{ if .Site.Params.favicon }}
<link rel="icon" href="{{ .Site.Params.favicon }}">
<!-- favicon -->
Expand Down