Skip to content

Commit e291308

Browse files
hellcpSorixelle
authored andcommitted
Add opengraph tags for embedding on social media
Signed-off-by: Stasia Michalska <[email protected]>
1 parent 07b08e1 commit e291308

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

source/_layouts/master.html

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,37 @@
1919
<head>
2020
<meta charset="utf-8">
2121
<meta http-equiv="X-UA-Compatible" content="IE=edge">
22-
<title>{% if page.title %}{{ page.title }} // {{ site.title }}{% else %}{{ site.title }}{% endif %}</title>
2322
<meta name="viewport" content="width=device-width,initial-scale=1">
24-
<meta name="description" content="{% if page.description %}{{ page.description }}{% else %}{{ site.description }}{% endif %}">
23+
<title>{% if page.title %}{{ page.title }} // {{ site.title }}{% else %}{{ site.title }}{% endif %}</title>
24+
<meta property="og:site_name" content="{{ site.title }}" />
25+
<meta property="og:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}" />
26+
<meta property="og:url" content="{{ page.url | absolute_url }}" />
27+
{% capture description %}{% if page.description %}{{ page.description }}{% elsif page.excerpt %}{{ page.excerpt }}{% elsif page.content %}{{ page.content }}{% else %}{{ site.description }}{% endif %}{% endcapture %}
28+
<meta property="og:description" content="{{ description | strip_html | truncate: 200 }}" />
29+
<meta name="description" content="{{ description | strip_html | truncate: 200 }}">
30+
{% if page.author %}
31+
<meta property="og:type" content="article" />
32+
<meta property="article:published_time" content="{{ page.date | date_to_xmlschema }}" />
33+
<meta property="article:author" content="{{ site.data.authors[page.author].name }}" />
34+
{% for tag in page.tags %}
35+
<meta property="article:tag" content="{{ tag }}" />
36+
{% endfor %}
37+
{% if page.banner %}
38+
<meta name="twitter:card" content="summary_large_image">
39+
<meta property="og:image" content="{{ site.asset_path | append: page.banner | absolute_url }}" />
40+
{% else %}
41+
{% assign author = site.data.authors[page.author] %}
42+
{% if author and author.photo %}
43+
<meta property="og:image" content="{{ author.photo }}" />
44+
{% else %}
45+
<meta property="og:image" content="{{ site.data.authors.pebble.photo }}" />
46+
{% endif %}
47+
{% endif %}
48+
{% else %}
49+
<meta property="og:type" content="website" />
50+
<meta property="og:image" content="{{ site.asset_path | append: '/images/rebble.png' | absolute_url }}" />
51+
{% endif %}
52+
<meta name="theme-color" content="#ff4700">
2553
<link rel="canonical" href="{{ page.url | replace: 'index.html', '' | prepend: site.baseurl | prepend: site.url }}">
2654
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,600,700" rel="stylesheet" type="text/css">
2755
<link href="https://fonts.googleapis.com/css?family=Inconsolata:400,700" rel="stylesheet" type="text/css">

source/assets/images/rebble.png

5.13 KB
Loading

0 commit comments

Comments
 (0)