Skip to content

Instantly share code, notes, and snippets.

@abhisheknaik96
Last active September 5, 2023 05:26
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save abhisheknaik96/26ce79ac7a307eb836dcf02a52f87cf2 to your computer and use it in GitHub Desktop.
Save abhisheknaik96/26ce79ac7a307eb836dcf02a52f87cf2 to your computer and use it in GitHub Desktop.
A tutorial on embedding a twitter stream to a Jekyll project.

Embedding a twitter stream in Jekyll

  1. Create a _plugins folder in your root.
  2. Add the following to _config.yml
plugins:
  - jekyll-gist
  1. If you don't have a Gemfile associated with your Jekyll project, create one with the following text
source 'https://rubygems.org'
group :jekyll_plugins do
    gem 'github-pages'
end
  1. Add the following to your Gemfile:
gem 'jekyll-twitter-plugin'
  1. Now you're ready to add the following tags in your html. (Check out more attributes from the Twitter API)
<div class='jekyll-twitter-plugin' align="center">
    {% twitter https://twitter.com/anaik96 maxwidth=500 limit=5 %}
</div>
  1. The job isn't done yet. The feed will show on your localhost, but not Gihub Pages, which will block all plugins because of safety reasons... -_-
    No problemo, just copy the generated content from _sites folder and replace the html of step 5! :)

Sources

  1. Github - jekyll-twitter-plugin
  2. Setting up your GitHub Pages site locally with Jekyll
  3. Documentation - Jekyll Plugins
@mzenk
Copy link

mzenk commented May 21, 2021

Thanks, this worked for me! :)
Edit: I only applied step 6, though, after first trying it the way it is described at the plugin repo locally.

@aymanzyy
Copy link

aymanzyy commented Jan 8, 2022

I am having trouble with this. What exactly are you referring to when you say copy the generated content? I've got it working locally but not sure what exactly to copy over and what exactly to replace the html from step 5 with.

@callebtc
Copy link

Anyone ending up here but not getting it to run (for me it was because of version conflicts of different gems): You can also embed a tweet directly as a html blockquote. Just put this in your post:

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">halfin (@halfin) <a href="https://twitter.com/halfin/status/1110302988">https://twitter.com/halfin/status/1110302988</a></p>&mdash; halfin (@halfin) <a href="https://twitter.com/halfin/status/1110302988"></a></blockquote>
<script async="" src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

@armannaj
Copy link

armannaj commented Sep 5, 2023

I explained it step by step on how to embed tweets in GitHub Pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment