Monday, August 31, 2009

Twitter button with pre-shortened URLs

I was stuck inside all weekend recovering from H1N1, so I spent some time creating the Bike Shorts URL shortening service for my use, but I'd be delighted if you used it also. Once I have a critical mass of links in the database you'll see recent and top links listed over there too.

My main motivation for this is to have my own pre-shortened URLs for my blog posts. I've had the "Tweet Meme" button at the top of my posts for a while, but I always thought they were a little clunky. At the bottom of this post you'll now see a tiny little Twitter button listed alongside the other social media buttons. Go ahead and try it if you want.

You can add this button with pre-shortened URLs to your own blog. The Javascript code you need to add looks like this:

<script type="text/javascript"
src="http://cycl.me/tweetme.php?f=js&text=post title&url=http://example.com/your/blog/post/">
</script>

Replace post title with the code for your blogging platform for the title of your post, and http://example.com/your/blog/post/ with the code for your permalink page URL. For Blogger.com, for example, add this code to your Template:

<script type="text/javascript"
src="http://cycl.me/tweetme.php?f=js&text=<$BlogItemTitle$>&url=<$BlogItemPermalinkUrl$>">
</script>

In Wordpress, you can add this code to your theme:

<script type="text/javascript"
src="http://cycl.me/tweetme.php?f=js&text=<$?php the_title() ;?>&url=<?php the_permalink() ;?>">
</script>

...or could just use the WP Plugin that auto-tweets each post. Point to http://cycl.me/ in the settings and you should be ready to go.

Please let me know what you think of Bike Shorts and what kinds of features you'd like to see with it.

Huge props to Steve Vance for some technical pointers and the domain name suggestion.

2 comments: