Better buttons for social media sharing

Do your bit to help keep the World Wide Web tidy.

28 May 2018
Post Tweet Share

The share buttons provided by the big social media platforms make it easy for your visitors to post a link to your site, but they also gum up the web with extra HTTP requests and hidden tracking cookies. The code snippets below make use of simple hyperlinks to power share buttons instead. This is better for load times and better for your visitors’ privacy too.

To style these like the classic buttons you’re used to seeing around the web, try Font Awesome for the brand logos and some simple CSS to set the button shapes and colours.

Don’t forget to URL encode the links you want to share, and add target="_blank" if you want the dialogs to open in a new window.


<a href="">Share on Facebook</a>

Doesn’t accept any other parameters (everything else is obtained automatically from your page’s Open Graph tags). It’s a derivative of the Share Button described here.


<a href="">Share on Twitter</a>

Also accepts the text, via and hashtags parameters. The link will render as a Twitter Card if your page has the correct markup. More info here.


<a href="">Share on LinkedIn</a>

Also accepts the title and summary parameters, though this info will be also be picked up automatically from your page’s Open Graph tags. More info here.