This is a little coding trick I get asked about quite a bit.
The link you have to make to share something to Twitter is quite simple:
http://twitter.com/share?text=text goes here
But getting a URL and hastag in there is a different matter. To be honest most developers do know how to include the URL, but hashtags have proved more elusive!
http://twitter.com/share?text=text goes here&url=http://url goes here&hashtags=hashtag1,hashtag2,hashtag3
Here’s an example to try out:
And that’s it!
Just what I was looking for. Thanks!
Greetings! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly? My web site looks weird when viewing from my iphone4. I’m
trying to find a theme or plugin that might be able to
resolve this problem. If you have any recommendations, please share.
With thanks!
I sure do!
Forget plugins, ideally you want responsive CSS so the same site delivers the appropriate layout to any device.
Thanks so much! This was just what I was looking for 🙂
Perfect! Exactly the tweet link I wanted.
The Twitter share code works perfectly.
thanks a lot. Exactly what is was looking for. Twitter Share Code worked Properly.
Hey man,
Do you happen to know a way to share shortlinks this way? The URL does not show up in the tweet when you don’t add a HTTP/HTTPS.
Best,
Nick
Short and sweet! Just what I need. Thanks!
Your code is working perfectly but do you have any idea why my site’s logo is not appearing in the tweet, it is displaying default images instead of the site logo in the tweet.
It’ll grab whatever the default image is on your page. Ideally you’d use Twitter card meta tags to set that sort of thing to whatever you prefer it to be.