Improving page speed by using static sharing links

7th February 2013

With social signals being the latest buzz word in SEO, it's never been more important to make your content easy to share. The quickest solution is to use a service such as ShareThis or AddThis to generate a chunk of code to add to your site. These services are great at what they do, but they do add a considerable amount of code to do what they do. Page speed is also a major factor in Google's algorithms so adding to your page's size isn't a great idea.

The answer? Make your own links!

I'm taking the big four for this example - Twitter, Facebook, Pinterest and Google Plus. Each of these has their own page to which data can be posted to add a link to their networks. As we're passing links in a link you must make sure that any locations are URL encoded. If you're generating these buttons for static pages, you can use this tool to generate your encoded links. As we're all about MODX at Studio Republic I'll also give you a snippet that will build the links for you for any resource.


Nice and easy this one 

<a href="" target="_blank">


<a href="[[sharelink:tag? &link=`1` &id=`[[*id:tag]]`]]" target="_blank">

Google Plus

Same idea here.

<a href="" target="_blank">


<a href="[[sharelink:tag? &link='1' &id='[[*id:tag]]']]" target="_blank">


Bit more complicated as we're building up a Tweet. The status can be anything you like but the example below gets your Twitter handle into the user's Tweet

<a href="" target="_blank">


<a href="[[sharelink:tag? &twitter='1' &id='[[*id:tag]]' &pagetitle='[[*longtitle:tag]]']]" target="_blank">


Pinterest needs an image to be set explicitly, hence the image placeholder below. 

<a href="" target="_blank">


<a href="[[sharelink:tag? &link='1' &id='[[*id:tag]]']]&media=[[urlencode:tag? &url='[[++site_url:tag]]IMAGE']]&description=[[urlencode:tag? &url='[[*longtitle:tag]]']]" target="_blank">

MODX Snippet

Here's the snippet I use to build and encode the links in MODX

if (isset($twitter)){
$link=$pagetitle.' '.$link.' via %40studiorepublic';
return urlencode($link);

 And the simple URL encoding snippet used on the Pinterest link:

return urlencode($url);

Empowering causes with the means to directly impact lives

B Corporation Certified
We plant trees with Ecologi
Registered office address
Hikenield House, East Anton Court, Icknield Way, Andover, Hampshire SP10 5RG


Hit up our positive impact newsletter to receive some good news in your inbox.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

© Copyright 2023 Studio Republic