Skip to content

Commit

Permalink
Improve open graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaspar Naaber committed Oct 8, 2014
1 parent 1c5964c commit e64fef3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 10 deletions.
37 changes: 37 additions & 0 deletions components/open-graph.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% comment %}https://developers.facebook.com/tools/debug - Debug after each modification{% endcomment %}
{% if site.data.fb_admin %}<meta property="fb:admins" content="{{ site.data.fb_admin }}">{% endif %}
<meta property="og:type" content="{% if article %}article{% else %}website{% endif %}">
<meta property="og:url" content="{{ site.url }}{% if article %}{{ article.url | remove_first:'/' }}{% else %}{{ page.url | remove_first:'/' }}{% endif %}">
<meta property="og:title" content="{{ page_title | escape }}">
<meta property="og:site_name" content="{{ page.site_title | escape }}">

{% comment %}Open Graph image{% endcomment %}
{% if front_page == true %}
{% unless page.data.cover_image == '' %}
{% if page.data.cover_image == nil %}
<meta property="og:image" content="{{ site.url }}{{ cover_image | remove_first: '/' }}">
{% else %}
<meta property="og:image" content="{{ cover_image }}">
{% endif %}
{% endunless %}
{% else %}
{% if article and article_cover_image != nil and article_cover_image != "" %}
<meta property="og:image" content="{{ article_cover_image }}">
{% elsif article and article.data.fb_image %}
<meta property="og:image" content="{{ article.data.fb_image }}">
{% elsif page.data.fb_image %}
<meta property="og:image" content="{{ page.data.fb_image }}">
{% elsif site.data.fb_image %}
<meta property="og:image" content="{{ site.data.fb_image }}">
{% endif %}
{% endif %}

{% comment %}Open Graph description{% endcomment %}
{% if blog and article == nil and (page.description == nil or page.description == "") %}
{% assign excerpt_description = articles.first.excerpt | strip_html | escape | strip_newlines | truncatewords: 200, '...' %}
<meta property="og:description" content="{{ excerpt_description }}">
<meta name="description" content="{{ excerpt_description }}">
{% else %}
<meta property="og:description" content="{% if article %}{{ article.description }}{% else %}{{ page.description }}{% endif %}">
<meta name="description" content="{% if article %}{{ article.description }}{% else %}{{ page.description }}{% endif %}">
{% endif %}
2 changes: 1 addition & 1 deletion layouts/blog___news.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html class="{% if editmode %}editmode{% else %}public{% endif %}" lang="{{ page.language_code }}">
<head prefix="og: http://ogp.me/ns#">
{% include "html-head" %}
{% include "edicy-tools-variables" %}
{% include "html-head" %}
</head>

<body class="blog-page js-body global-background-color {{ background_type }}-background" {% if background_color != '' or editmode %}{{ background_color_style}}{% endif %}>
Expand Down
2 changes: 1 addition & 1 deletion layouts/blog_article.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html class="{% if editmode %}editmode{% else %}public{% endif %}" lang="{{ page.language_code }}">
<head prefix="og: http://ogp.me/ns#">
{% include "html-head" %}
{% include "edicy-tools-variables" %}
{% include "edicy-tools-article-variables" %}
{% include "html-head" %}
{{ site.stats_header }}
</head>

Expand Down
2 changes: 1 addition & 1 deletion layouts/common_page.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html class="{% if editmode %}editmode{% else %}public{% endif %}" lang="{{ page.language_code }}">
<head prefix="og: http://ogp.me/ns#">
{% include "html-head" %}
{% include "edicy-tools-variables" %}
{% include "html-head" %}
</head>

<body class="common-page js-body global-background-color {{ background_type }}-background" {% if background_color != '' or editmode %}{{ background_color_style}}{% endif %}>
Expand Down
3 changes: 2 additions & 1 deletion layouts/front_page.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!DOCTYPE html>
<html class="{% if editmode %}editmode{% else %}public{% endif %}" lang="{{ page.language_code }}">
<head prefix="og: http://ogp.me/ns#">
{% include "html-head" %}
{% assign front_page = true %}
{% include "edicy-tools-variables" %}
{% include "html-head" %}
</head>

<body class="front-page js-body global-background-color {{ background_type }}-background" {% if background_color != '' or editmode %}{{ background_color_style}}{% endif %}>
Expand Down
19 changes: 13 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,18 @@
"title": "menu-mobile"
},
{
"content_type": "blog",
"component": false,
"file": "layouts/blog___news.tpl",
"layout_name": "blog",
"title": "Blog & News"
"content_type": "component",
"component": true,
"file": "components/news.tpl",
"layout_name": "news",
"title": "news"
},
{
"content_type": "component",
"component": true,
"file": "components/open-graph.tpl",
"layout_name": "open-graph",
"title": "open-graph"
},
{
"content_type": "component",
Expand Down Expand Up @@ -198,7 +205,7 @@
"content_type": "component",
"component": true,
"file": "components/voog-ref.tpl",
"layout_name": "",
"layout_name": "voog-ref",
"title": "voog-ref"
}
],
Expand Down

0 comments on commit e64fef3

Please sign in to comment.