Skip to content

scottwb/jekyll-tweet-tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

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

About

Embed tweets in Jekyll/Octopress blogs using Twitter's oEmbed API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published