Permalink
Browse files

Add meta tags for sharing articles and pages

  • Loading branch information...
textbook committed Dec 4, 2016
1 parent 0375393 commit 78579cb3dba20c52a7f12f98a4e3cfbe2bbac051
Showing with 30 additions and 2 deletions.
  1. +3 −2 README.md
  2. +5 −0 templates/article.html
  3. +2 −0 templates/base.html
  4. +15 −0 templates/meta_tags.html
  5. +5 −0 templates/page.html
@@ -16,13 +16,14 @@ Features
on tablet (≥769px), single column on mobile. Tabbed navigation bar collapses
into drop-down "burger menu" on mobile.

** Meta tagging functionality** - support for [Open Graph][5] and [Twitter
** Meta tagging functionality** - support for [Open Graph][5] and [Twitter
Cards][6] meta tags, giving enhanced display when sharing articles on social
media sites.
media sites (**note**: *currently only available for [articles and pages][7]*).

[1]: http://bulma.io/
[2]: http://docs.getpelican.com/en/stable/
[3]: http://fontawesome.io/
[4]: https://github.com/simonwhitaker/github-fork-ribbon-css
[5]: http://ogp.me/
[6]: https://dev.twitter.com/cards/overview
[7]: http://docs.getpelican.com/en/3.6.3/content.html#articles-and-pages
@@ -1,5 +1,10 @@
{% extends "base.html" %}
{% block title %}{{ article.title|striptags }}{% endblock %}
{% block tags %}
{% with item=article %}
{% include 'meta_tags.html' %}
{% endwith %}
{% endblock %}
{% block content %}
<section id="content" class="body">
<article>
@@ -14,6 +14,8 @@
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
{% block tags %}
{% endblock %}
</head>

<body id="index" class="home">
@@ -0,0 +1,15 @@
<meta property="og:title" content="{{ SITENAME }}{% if item.title %} - {{ item.title }}{% endif %}">
{% if item.summary %}
<meta property="og:description" content="{{ item.summary | striptags | truncate(200, end='...') }}">
{% endif %}
<meta property="og:url" content="{{ SITEURL }}/{{ item.url }}">
{% if AVATAR %}
<meta property="og:image" content="{{ SITEURL }}/images/{{ AVATAR }}">

<meta name="twitter:image:alt" content="{{ SITENAME }}{% if SITESUBTITLE %} | {{ SITESUBTITLE }}{% endif %}">
{% endif %}
<meta name="twitter:card" content="summary">
{% if TWITTER_USERNAME %}
<meta name="twitter:creator" content="@{{ TWITTER_USERNAME }}">
<meta name="twitter:site" content="@{{ TWITTER_USERNAME }}">
{% endif %}
@@ -1,5 +1,10 @@
{% extends "base.html" %}
{% block title %}{{ page.title }}{% endblock %}
{% block tags %}
{% with item=page %}
{% include 'meta_tags.html' %}
{% endwith %}
{% endblock %}
{% block content %}
<section id="content" class="body">
<h1 class="title"><a href="{{ SITEURL }}/{{ page.url }}" rel="bookmark"

0 comments on commit 78579cb

Please sign in to comment.