From 31099533fa926648b37f5913aa21925f382b7390 Mon Sep 17 00:00:00 2001 From: "Mr. Senko" Date: Fri, 12 Feb 2016 15:17:34 +0200 Subject: [PATCH] Update meta tags and add support for og:image --- README.md | 8 +++++++- templates/article.html | 44 ++++++++++++++++++++++++++++++++++-------- templates/base.html | 2 -- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b367010..8727174 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,11 @@ Accept many analytics: ### Articles -To customize header cover to articles, insert the metadata ``header_cover``: +To customize header cover to articles, insert the metadata ``header_cover``. +To customize OpenGraph images, insert the metadata ``og_image``, otherwise +``header_cover``, ``HEADER_COVER`` or a default image is used. You can also +use absolute URLs for ``og_image``. Example: + - To RST ```rst @@ -113,6 +117,7 @@ My super title :authors: Alexis Metaireau, Conan Doyle :summary: Short version for index and feeds :header_cover: /images/posts/super-title/cover.png +:og_image: /images/posts/super-title/facebook_cover.png ``` - To Markdown @@ -126,6 +131,7 @@ Slug: my-super-post Authors: Alexis Metaireau, Conan Doyle Summary: Short version for index and feeds Header_Cover: /images/posts/super-title/cover.png +Og_Image: http://example.com/facebook_cover.png This is the content of my super blog post. ``` diff --git a/templates/article.html b/templates/article.html index 943f0aa..12332b0 100755 --- a/templates/article.html +++ b/templates/article.html @@ -5,28 +5,56 @@ {{ super() }} {% for keyword in article.keywords %} - + {% endfor %} - {% for description in article.description %} - + {% if description %} + + {% elif article.headline %} + + {% elif article.summary %} + + {% endif %} + + {% for author in article.authors %} + {% endfor %} {% for tag in article.tags %} - + {% endfor %} - {% endblock %} {% block opengraph %} {{ super() }} - + {% for author in article.authors %} + + {% endfor %} - - + {% if description %} + + {% elif article.headline %} + + {% elif article.summary %} + + {% endif %} + + {% if article.og_image %} + {% if article.og_image|lower|truncate(4, True, '') == "http" %} + + {% else %} + + {% endif %} + {% elif article.header_cover %} + + {% elif HEADER_COVER %} + + {% else %} + + {% endif %} {% endblock %} {% block header %} diff --git a/templates/base.html b/templates/base.html index 0c4c777..5f2be18 100644 --- a/templates/base.html +++ b/templates/base.html @@ -6,8 +6,6 @@ - - {% if GOOGLE_SITE_VERIFICATION %}