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
- Semantic
- SEO Best Practices
- Open Graph
- Rich Snippets (JSON-LD)
## Integrations
@ -24,14 +26,17 @@ See what you can customize.
| Name | What does it do? |
|:----:|------------------|
| AUTHOR_SHORT_DESC | Short description to show below author name. |
| AUTHOR_IMG_URL | Profile picture to show above author name. |
| SITETITLE | Site title to show in sidebar. |
| 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. |
| 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. |
| 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. |
| MAIN_MENU | Show main menu. |
| ROBOTS | Robots meta tag value. |
| DISQUS_SITENAME | Disqus website's shortname to activate Disqus. |
| GOOGLE_ANALYTICS | Activate Google Analytics. |
| GOOGLE_TAG_MANAGER | Activate Google Tag Manager. |
@ -40,8 +45,13 @@ See what you can customize.
### Example
```python
AUTHOR_SHORT_DESC = 'Web Developer
AUTHOR_IMG_URL = '/static/img/me.png'
SITENAME = 'Foo Bar's Blog'
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
CC_LICENSE = { 'name': 'Creative Commons Attribution-ShareAlike', 'version':'4.0', 'slug': 'by-sa') }
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? |
|:----:|------------------|
| 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.
If the article has a custom Summary, the custom summary is shown.

View file

@ -1,6 +1,10 @@
{% 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 %}
{% block title %}&ndash; {{ article.title }}{% endblock %}
@ -26,3 +30,7 @@
{% include "partial/disqus.html" %}
</article>
{% 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/font-awesome.min.css">
{% 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 %}
{% 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 %}
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="index, follow">
<meta name="author" content="{{ AUTHOR }}">
<meta name="description" content="{{ AUTHOR }}'s Thoughts and Writings">
<title>{{ SITENAME }}{% block title %}{% endblock %}</title>
{% block head %}
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="{{ ROBOTS }}" />
{% block meta %}
<meta name="author" content="{{ AUTHOR }}" />
<meta name="description" content="{{ SITEDESCRIPTION }}" />
{% include "partial/og.html" %}
{% endblock %}
<title>{{ SITENAME }}{% block title %}{% endblock %}</title>
</head>
<body>
{% include "partial/gtm.html" %}
<aside>
<div class="profile">
<a href="{{ SITEURL }}">
{% if AUTHOR_IMG_URL %}
<img src="{{ AUTHOR_IMG_URL }}" alt="{{ AUTHOR }}" title="{{ AUTHOR }}">
{% if SITELOGO %}
<img src="{{ SITELOGO }}" alt="{{ SITETITLE }}" title="{{ SITETITLE }}">
{% else %}
<img src="{{ SITEURL }}/theme/img/profile.png" alt="{{ AUTHOR }}" title="{{ AUTHOR }}">
<img src="{{ SITEURL }}/theme/img/profile.png" alt="{{ SITETITLE }}" title="{{ SITETITLE }}">
{% endif %}
</a>
<h1><a href="{{ SITEURL }}">{{ AUTHOR }}</a></h1>
{% if AUTHOR_SHORT_DESC %}
<p>{{ AUTHOR_SHORT_DESC }}</p>
{% endif %}
<h1><a href="{{ SITEURL }}">{{ SITETITLE }}</a></h1>
<p>{{ SITESUBTITLE }}</p>
<nav>
<ul class="list">
{% for page in pages|sort %}
@ -79,22 +78,7 @@
<footer>
{% if CC_LICENSE %}
<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>
{% include "partial/cc_license.html" %}
{% else %}
<p>&copy; {{ AUTHOR }} {{ COPYRIGHT_YEAR }}</p>
{% include "partial/flex.html" %}

View file

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