How to Create Short Retweet Urls for Your Domain Name

How to create short urls from your own domain name to make it east to retweet? Its easy to link to short urls instead of the long keyword stuffed urls bloggers generate for SEO purposes. We are using these short url redirects and this article is the answer to how we do it on our site.

While there are many short url services you can use like bit.ly, ow.ly, tinyurl.com, wp.me etc., there is nothing better than your own domain name short url which looks better for retweeting and expresses your brand better on Twitter.

short retweet urls

Which do you prefer?

https://www.quickonlinetips.com/archives/leverage-browser-caching-increase-website-speed/
or

I prefer we get retweeted like this, and this is what our Twitter button does.

short url tweeted

In an attempt to increase our site speed, we removed the Tweetmeme retweet button and its time consuming javascripts, and added a manually coded tweet it button.  But if we linked to our complete url, then there was no space for adding post title and the long url filled up all 140 characters allowed by Twitter.

Usual Twitter Tweet it Links

A normal code posting to Twitter like a text link would look like this

<a href="http://twitter.com/home?status=<?php the_permalink(); ?>">Tweet this</a>

Here is the same code when applied to a twitter image

<a href="http://twitter.com/home?status=<?php the_permalink(); ?>"><img src="/tweet.png"></a>

Retweet with your Own Domain Name Short Urls

The beauty of WordPress is that every single post has a unique Post ID, besides the usual keyword rich long url we all like. So the key is to call this post ID url, which would redirect automatically to your long keyword url since you saved permalinks in such a way.

So basically for every permalink url
<?php the_permalink(); ?>

there is also a Post ID url, so in our case
the_ID(); ?>

1. If you want to link to the short url, then the tweet links look like this

<a href="http://twitter.com/home?status=http://www.quickonlinetips.com/?p=<?php the_ID(); ?>">Tweet this</a>

2. Now we want this link to open in a new window / tab, so add the target

<a href="http://twitter.com/home?status=http://www.quickonlinetips.com/?p=<?php the_ID(); ?>" target="_blank">Tweet this</a>

3. Now lets remove the www and make it even shorter

<a href="http://twitter.com/home?status=http://quickonlinetips.com/?p=<?php the_ID(); ?>" target="_blank">Tweet this</a>

4. We can also fit in the post title and RT @qot (our twitter url), so the the final code would look like

<a href="http://twitter.com/home?status=http://quickonlinetips.com/?p=<?php the_ID(); ?>

<?php the_title(); ?> RT @qot" target="_blank">Tweet this</a>

5. We decided to add a tweet this image so our final code would look like this

<a href="http://twitter.com/home?status=http://quickonlinetips.com/?p=<?php the_ID(); ?> <?php the_title(); ?> RT @qot" target="_blank"><img src="/tweet.png" width="96" height="19" border="0" alt="tweet"></a>

Now you can create short urls for your own domain name which are very useful and gives you all the branding you need on Twitter.

Share with friends

About the Author: P Chandra is editor of QOT, one of India's earliest tech bloggers since 2004. A tech enthusiast with expertise in coding, WordPress, web tools, SEO and DIY hacks.