How do I share to Facebook and other social media platforms?

Hi guys,

I’m looking to include a share icon that will allow users to share the page they are on to Facebook. I’ve searched around and just cannot understand the instructions for added functionality I have found on how to do this.

Can anyone give me a hand with this please.

I have my mark-up:


<ul class="socMedia">
    <li class="facebook">
        <a href="" onClick="shareFb()">
            <script>
		function shareFb()    {
                                	var sharer = "https://www.facebook.com/sharer/sharer.php?u=";
					
					window.open(sharer + location.href, 'sharer', 'width=626,height=436');
					}
            </script>
            Facebook
            <b></b>
        </a>
    </li>
</ul>

This works at a basic level, however I want to add to it so the page title and a description (adding meta tags for a description on the page?) are added in the pop-up window.

Additionally, will this work on a mobile platform?

Social media sites provide code that you can place onto your site that automatically generates all that functionality. There are also lote of tutes on how to add the code, such as this one for Facebook:

I prefer not to have lots of iframes and JS on my pages, so I put together a few tips a few years ago on how to do this without them, if that’s any help.