Wednesday 31 July 2013

Embedding tweets in posts

I just bumped into a tweet from @AlternativeChat remarking that she just figured out how to embed a tweet in a blog post. Well, that sounds interesting to me, so let's try.

First, here is the result:

The process is described in detail on twitter's website. If you are using some kind of what-you-see-is-what-you-get front-end for your blog editing (as is default for Blogger) you will need to switch to raw HTML editing mode before you can insert that snippet that you copy from twitter, of course. So some familiarity with HTML comes in handy.

Multiple tweets in one post

One thing to keep in mind is that the snippet from twitter contains two elements - a "<blockquote>" element and a "<script>" element. If you want to embed multiple tweets I guess you should make sure that the "<script>" element only appears once, for instance at end of your blog post. Each embedded tweet is described with a "<blockquote>" element; the script only needs to run once to turn all those blockquotes into more fancily displayed tweets.

The proof of the pudding is in the eating of course, so here is a second tweet (the followup to the one above)

Note that in this post I moved the "<script>" element (they are equal for both tweets) to the end of the post - and only left one of the two.

No comments:

Post a Comment