Add OG and Rich Snippets.

This commit is contained in:
Alexandre Vicenzi 2015-07-19 23:34:54 -03:00
parent 40dc516ef8
commit c2d323d09f
4 changed files with 42 additions and 38 deletions

View file

@ -8,6 +8,8 @@ A minimalist [Pelican](http://blog.getpelican.com/) theme.
- Responsive - Responsive
- Semantic - Semantic
- SEO Best Practices - SEO Best Practices
- Open Graph
- Rich Snippets (JSON-LD)
## Integrations ## Integrations
@ -24,14 +26,17 @@ See what you can customize.
| Name | What does it do? | | Name | What does it do? |
|:----:|------------------| |:----:|------------------|
| AUTHOR_SHORT_DESC | Short description to show below author name. | | SITETITLE | Site title to show in sidebar. |
| AUTHOR_IMG_URL | Profile picture to show above author name. | | 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. |
| COPYRIGHT_YEAR | Copyright year to display on footer. | | COPYRIGHT_YEAR | Copyright year to display on footer. |
| CC_LICENSE | Creative Commons License to show 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. | | MENUITEMS | A list of tuples (Title, URL) for additional menu items to appear on main menu. |
| LINKS | A list of tuples (Title, URL) for links to appear on the sidebar menu. | | LINKS | A list of tuples (Title, URL) for links to appear on the sidebar menu. |
| SOCIAL | A list of tuples (name, URL) to appear in the "social" section. | | SOCIAL | A list of tuples (name, URL) to appear in the "social" section. |
| MAIN_MENU | Show main menu. | | MAIN_MENU | Show main menu. |
| ROBOTS | Robots meta tag value. |
| DISQUS_SITENAME | Disqus website's shortname to activate Disqus. | | DISQUS_SITENAME | Disqus website's shortname to activate Disqus. |
| GOOGLE_ANALYTICS | Activate Google Analytics. | | GOOGLE_ANALYTICS | Activate Google Analytics. |
| GOOGLE_TAG_MANAGER | Activate Google Tag Manager. | | GOOGLE_TAG_MANAGER | Activate Google Tag Manager. |
@ -40,8 +45,13 @@ See what you can customize.
### Example ### Example
```python ```python
AUTHOR_SHORT_DESC = 'Web Developer SITENAME = 'Foo Bar's Blog'
AUTHOR_IMG_URL = '/static/img/me.png' SITETITLE = 'Foo Bar'
SITESUBTITLE = 'Web Developer'
SITEDESCRIPTION = 'Foo Bar\'s Thoughts and Writings'
SITELOGO = 'http://yoursite.com/img/profile.png'
ROBOTS = 'index, follow'
COPYRIGHT_YEAR = 2015 COPYRIGHT_YEAR = 2015
CC_LICENSE = { 'name': 'Creative Commons Attribution-ShareAlike', 'version':'4.0', 'slug': 'by-sa') } CC_LICENSE = { 'name': 'Creative Commons Attribution-ShareAlike', 'version':'4.0', 'slug': 'by-sa') }
MAIN_MENU = True MAIN_MENU = True
@ -89,7 +99,8 @@ If you need more icons, you will need to add a custom background to keep all ico
| Name | What does it do? | | Name | What does it do? |
|:----:|------------------| |:----:|------------------|
| Summarise | Enable Home summary | | Summarise | Enable Home summary. |
| Cover | Cover image for social sharing (absolute url). |
By default, all article content is shown on Home. By default, all article content is shown on Home.
If the article has a custom Summary, the custom summary is shown. If the article has a custom Summary, the custom summary is shown.

View file

@ -1,6 +1,10 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block head %}
<meta name="keywords" content="{{ article.tags|join(', ') }}"> {% block meta %}
<meta name="author" content="{{ article.author.name }}" />
<meta name="description" content="{{ article.summary|striptags }}" />
<meta name="keywords" content="{{ article.tags|join(', ') }}">
{% include "partial/og_article.html" %}
{% endblock %} {% endblock %}
{% block title %}&ndash; {{ article.title }}{% endblock %} {% block title %}&ndash; {{ article.title }}{% endblock %}
@ -26,3 +30,7 @@
{% include "partial/disqus.html" %} {% include "partial/disqus.html" %}
</article> </article>
{% endblock %} {% endblock %}
{% block additional_js %}
{% include "partial/jsonld_article.html" %}
{% endblock %}

View file

@ -11,36 +11,35 @@
<link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/pygments.min.css"> <link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/pygments.min.css">
<link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/font-awesome.min.css">
{% if FEED_ALL_ATOM %} {% if FEED_ALL_ATOM %}
<link href="{{ FEED_DOMAIN }}/{{ FEED_ALL_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Atom" /> <link href="{{ FEED_DOMAIN }}/{{ FEED_ALL_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Atom">
{% endif %} {% endif %}
{% if FEED_ALL_RSS %} {% if FEED_ALL_RSS %}
<link href="{{ FEED_DOMAIN }}/{{ FEED_ALL_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} RSS" /> <link href="{{ FEED_DOMAIN }}/{{ FEED_ALL_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} RSS">
{% endif %} {% endif %}
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="index, follow"> <meta name="robots" content="{{ ROBOTS }}" />
<meta name="author" content="{{ AUTHOR }}"> {% block meta %}
<meta name="description" content="{{ AUTHOR }}'s Thoughts and Writings"> <meta name="author" content="{{ AUTHOR }}" />
<title>{{ SITENAME }}{% block title %}{% endblock %}</title> <meta name="description" content="{{ SITEDESCRIPTION }}" />
{% block head %} {% include "partial/og.html" %}
{% endblock %} {% endblock %}
<title>{{ SITENAME }}{% block title %}{% endblock %}</title>
</head> </head>
<body> <body>
{% include "partial/gtm.html" %} {% include "partial/gtm.html" %}
<aside> <aside>
<div class="profile"> <div class="profile">
<a href="{{ SITEURL }}"> <a href="{{ SITEURL }}">
{% if AUTHOR_IMG_URL %} {% if SITELOGO %}
<img src="{{ AUTHOR_IMG_URL }}" alt="{{ AUTHOR }}" title="{{ AUTHOR }}"> <img src="{{ SITELOGO }}" alt="{{ SITETITLE }}" title="{{ SITETITLE }}">
{% else %} {% else %}
<img src="{{ SITEURL }}/theme/img/profile.png" alt="{{ AUTHOR }}" title="{{ AUTHOR }}"> <img src="{{ SITEURL }}/theme/img/profile.png" alt="{{ SITETITLE }}" title="{{ SITETITLE }}">
{% endif %} {% endif %}
</a> </a>
<h1><a href="{{ SITEURL }}">{{ AUTHOR }}</a></h1> <h1><a href="{{ SITEURL }}">{{ SITETITLE }}</a></h1>
{% if AUTHOR_SHORT_DESC %} <p>{{ SITESUBTITLE }}</p>
<p>{{ AUTHOR_SHORT_DESC }}</p>
{% endif %}
<nav> <nav>
<ul class="list"> <ul class="list">
{% for page in pages|sort %} {% for page in pages|sort %}
@ -79,22 +78,7 @@
<footer> <footer>
{% if CC_LICENSE %} {% if CC_LICENSE %}
<p> {% include "partial/cc_license.html" %}
&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>
{% else %} {% else %}
<p>&copy; {{ AUTHOR }} {{ COPYRIGHT_YEAR }}</p> <p>&copy; {{ AUTHOR }} {{ COPYRIGHT_YEAR }}</p>
{% include "partial/flex.html" %} {% include "partial/flex.html" %}

View file

@ -35,5 +35,6 @@
{% endblock %} {% endblock %}
{% block additional_js %} {% block additional_js %}
{% include "partial/jsonld.html" %}
{% include "partial/disqus_count.html" %} {% include "partial/disqus_count.html" %}
{% endblock %} {% endblock %}