Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Embed tweets in Jekyll/Octopress blogs using Twitter's oEmbed API.
branch: master
Failed to load latest commit information.
README.md Update README.md
tweet_tag.rb Initial implementation of working `tweet` tag for Jekyll.

README.md

Liquid Tweet Tag for Jekyll and Octopress

This is a simple Liquid tag that makes it easy to embed tweets. This is great for quoting a tweet in a blog post, for example. It uses Twitter's oEmbed API for their Embedded Tweet feature. Features include:

  • Easy to install
  • Easy to embed tweets
  • Displays tweets with familiar twitter style
  • Optional parameters to control layout (as described in Twitter's oEmbed API)
  • Provides twitter features such as retweet, follow, and favorite without leaving your page

How To Install

  1. Copy tweet_tag.rb into <your-jekyll-project>/_plugins or <your-ocotpress-project>/plugins.
  2. That is all.

How To use

Place a tweet tag in your content file, using the URL to the tweet, e.g.:

{% tweet https://twitter.com/DEVOPS_BORAT/statuses/159849628819402752 %}

You can also just copy the Wordpress shortcode generated by Twitter's "Embed this Tweet" UI and change the [...] to {% ... %}. For example:

{% tweet https://twitter.com/DEVOPS_BORAT/status/159849628819402752 align='right' width='350' %}

The first argument to the tweet tag must be the tweet URL, but everything after that is optional. You can pass any parameter supported by the Twitter oEmbed API in the form key='value'.

In an attempt to maintain compatibility with Robert Böhnke's Embed.ly Tag, the tweet tag wraps the embedded code with a <div class='embed tweet'>.

Caching

The Twitter oEmbed API is rate-limited. The tweet tag caches all API responses in a directory named .tweet-cache. This way, regenerating your site does not re-query for every embedded tweet every time. You can safely delete the .tweet-cache directory. It will be recreated and embedded tweets will be re-queried.

You can also use the tweetnocache tag to embed a tweet that bypasses the cache. This is not recommended since it will request the embed code from twitter every time that page is regenerated.

Author

Scott W. Bradley -- http://scottwb.com

Credits

This code is inspired by the Gist Tag plugin by Brandon Tilley and the oEmbed Tag by Tammo van Lessen.

License

This code is licensed under Apache License 2.0

Something went wrong with that request. Please try again.