Constructing a hyperlink to share content onto Twitter (Misc)

Nowadays, most sites will find that the majority of their traffic arrives as the result of someone else sharing or "likeing" the content on Social Media. As a result, it's desirable to make the act of sharing as easy as possible.

The various social networks often provide "share this" widgets that can be embedded into sites. However, these involve the user's browser requesting resources from the social network, and these requests are known to be data-mined in order to track users across the web and profile their browsing habits (to better sell ads).

However, most social media networks do make it possible to create a share button which works via a simply hyperlink.

This snippet details how to construct a link which shares a page onto Twitter. You can see an example of how to put this into practice as a share button inside a site's template here

Details

  • Language: Misc

Snippet

https://twitter.com/share?text=<default tweet text>&url=<url>&via=<your twitter handle>

Usage Example

https://twitter.com/share?text=The+home+of+Ben+Tasker&url=https://www.bentasker.co.uk&via=bentasker