Skip to content

Instantly share code, notes, and snippets.

@voxpelli
Created March 9, 2012 10:20
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voxpelli/2005961 to your computer and use it in GitHub Desktop.
Save voxpelli/2005961 to your computer and use it in GitHub Desktop.
Adding Flattr in Jekyll

This is the three parts that I'm using on my Jekyll blog (http://voxpelli.com/) to add Flattr.

I add the "default.html" part in the bottom of the default layouts HTML (the one used by posts). I add it just prior to closing body-tag. Make sure to change the "uid" parameter in the s.src variable to be your Flattr username.

I then add the a-tag in "post.html" in the place where I want the flattr button to appear. Since my blog supports both swedish and english posts I define a language attribute - if you don't use that in your Jekyll-blog then feel free to leave it out. Just be sure to change the domain in the href-attribute to be to your site.

Lastly I add the "default_head.html" part in the head-section of the default layouts HTML (the one used by posts). I also define a language attribute here - if you don't use such an attribute in your Jekyll-blog then switch it to something else or leave it out. Make sure to change the domain and to change the "uid" parameter in the s.src variable to be your own domain and Flattr username.

More options available can be found in the documentation: http://developers.flattr.net/button/ You can also ask me on Twitter - I'm @voxpelli there.

<script type="text/javascript">
(function() {
var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
s.type = 'text/javascript';
s.async = true;
s.src = '//api.flattr.com/js/0.6/load.js?mode=auto&button=compact&uid=test&category=text';
t.parentNode.insertBefore(s, t);
})();
</script>
{% if page.flattrable != null %}
<link rel="payment" type="text/html" href="https://flattr.com/submit/auto?url=http%3A%2F%2Fexample.com{{ page.url | cgi_escape }}&amp;user_id=test&amp;title={{ page.title | cgi_escape }}&amp;category=text&amp;tags=blog&amp;language={% if page.lang == 'en' %}en{% else %}se{% endif %}" title="Flattr this post" />
{% endif %}
<a class="FlattrButton" href="http://example.com{{ page.url }}" title="{{ page.title }}" lang="{% if page.lang == 'en' %}en{% else %}se{% endif %}" rel="flattr;tags:blog;"></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment