OG and Rich Snippets.

This commit is contained in:
Alexandre Vicenzi 2015-07-20 01:52:02 -03:00
parent c2d323d09f
commit c6255cf531
6 changed files with 85 additions and 0 deletions

View file

@ -30,6 +30,7 @@ See what you can customize.
| SITESUBTITLE | Short description to show below subtitle. |
| SITELOGO | Profile picture to show above author name (absolute url). |
| SITEDESCRIPTION | Site description to use in meta tags. |
| OG_LOCALE | language_TERRITORY for Open Graph. Default is `en_US`. |
| COPYRIGHT_YEAR | Copyright year to display on footer. |
| CC_LICENSE | Creative Commons License to show on footer. |
| MENUITEMS | A list of tuples (Title, URL) for additional menu items to appear on main menu. |
@ -101,6 +102,7 @@ If you need more icons, you will need to add a custom background to keep all ico
|:----:|------------------|
| Summarise | Enable Home summary. |
| Cover | Cover image for social sharing (absolute url). |
| OgLocale | Open graph locale. |
By default, all article content is shown on Home.
If the article has a custom Summary, the custom summary is shown.

View file

@ -0,0 +1,17 @@
<p>
&copy; {{ AUTHOR }} {{ COPYRIGHT_YEAR }} - This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/{{ CC_LICENSE['slug'] }}/{{ CC_LICENSE['version'] }}/">{{ CC_LICENSE['name'] }} {{ CC_LICENSE['version'] }} International License</a>
</p>
{% include "partial/flex.html" %}
<p>
<a rel="license"
href="http://creativecommons.org/licenses/{{ CC_LICENSE['slug'] }}/{{ CC_LICENSE['version'] }}/"
target="_blank">
<img alt="Creative Commons License"
title="Creative Commons License"
style="border-width:0"
src="https://i.creativecommons.org/l/{{ CC_LICENSE['slug'] }}/{{ CC_LICENSE['version'] }}/80x15.png"
width="80"
height="15"/>
</a>
{% include "partial/statuscake.html" %}
</p>

View file

@ -0,0 +1,10 @@
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Blog",
"name": " {{ SITENAME }} ",
"url" : "{{ SITEURL }}",
"image": "{{ SITELOGO }}",
"description": "{{ SITEDESCRIPTION }}"
}
</script>

View file

@ -0,0 +1,23 @@
{% if SITELOGO %}
{% set default_cover = SITELOGO %}
{% else %}
{% set default_cover = '{{ SITEURL }}/theme/img/profile.png' %}
{% endif %}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"name": "{{ article.title }}",
"headline": "{{ article.title }}",
"datePublished": "{{ article.date }}",
"dateModified": "{{ article.modified }}",
"author": {
"@type": "Person",
"name": "{{ article.author.name }}",
"url": "{{ SITEURL }}/{{ article.author.url }}"
},
"image": "{{ article.metadata.get('cover', default_cover) }}",
"url": "{{ SITEURL }}/{{ article.url }}",
"description": "{{ article.summary|striptags }}"
}
</script>

14
templates/partial/og.html Normal file
View file

@ -0,0 +1,14 @@
{% if OG_LOCALE %}
{% set default_locale = OG_LOCALE %}
{% else %}
{% set default_locale = 'en_US' %}
{% endif %}
<meta property="og:site_name" content="{{ SITENAME }}"/>
<meta property="og:type" content="blog"/>
<meta property="og:title" content="{{ SITENAME }}"/>
<meta property="og:description" content="{{ SITEDESCRIPTION }}"/>
<meta property="og:locale" content="{{ default_locale }}"/>
<meta property="og:url" content="{{ SITEURL }}"/>
{% if SITELOGO %}
<meta property="og:image" content="{{ SITELOGO }}">
{% endif %}

View file

@ -0,0 +1,19 @@
{% if OG_LOCALE %}
{% set default_locale = OG_LOCALE %}
{% else %}
{% set default_locale = 'en_US' %}
{% endif %}
<meta property="og:site_name" content="{{ SITENAME }}"/>
<meta property="og:title" content="{{ article.title }}"/>
<meta property="og:description" content="{{ article.summary|striptags }}"/>
<meta property="og:locale" content="{{ article.metadata.get('og_locale', default_locale) }}"/>
<meta property="og:url" content="{{ SITEURL }}/{{ article.url }}"/>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="{{ article.date }}"/>
<meta property="article:modified_time" content="{{ article.modified }}"/>
<meta property="article:author" content="{{ SITEURL }}/{{ article.author.url }}">
<meta property="article:section" content="{{ article.category.name }}"/>
{% for tag in article.tags %}
<meta property="article:tag" content="{{ tag.name }}"/>
{% endfor %}
<meta property="og:image" content="{{ article.metadata.get('cover', SITELOGO) }}">