The canonical tag has been a god send for us helping to get pages indexed and clean up site structures. In many sites we use the same php variable for our share buttons.
This is a great way to setup custom twitter and facebook share buttons for your pages. We always use an external template file and then include it from the pages but you can hard code this into a single web page if required.
The images are currently set to images/facebookpic.png and images/twitterpic.png You could set it to http://www.facebook.com/favicon.ico if you’re feeling lazy or google image search facebook button for examples. You could get pretty creative with this if you are aiming to give your site a social/seo boost.
<?php
// declare the variables from a seperate page and include(‘mytemplate.php’) or put it all in one page.
$title = ‘My title’;
$canonical = ‘http://www.JetInternetMarketing.co.uk/index.php’;
//output the tags required in <head> obviously meta descriptions etc would be added too.
echo ‘<title>’.$title.'</title>
<link rel=”canonical” href=”‘.$canonical.’” />’;
// Buttons below for <body> section. Note there is no follow me function added to the twitter code, this can be added if required.
$fblink = “http://www.facebook.com/sharer.php?u=”.$canonical.”&t=”.urlencode($title).”&src=sp”;
echo(‘<a title=”Share on Facebook” href=”‘.$fblink.’” target=”_blank”><img src=”images/facebookpic.png” alt=”facebook like” border=”0″ /></a>’);
$twitlink = “http://twitter.com/share?_=1292093673417&count=horizontal&original_referer=”.$canonical.”&text=”.urlencode($title).”&url=”.$canonical;
echo(‘ <a title=”Share on Twitter” href=”‘.$twitlink.’” target=”_blank”><img src=”images/twitterpic.png” alt=”twitter retweet” border=”0″ /></a> ‘);
‘;
?>