Forum

Thread tagged as: Question, Problem, Addons

Social Media sharing links to blog post

Hi there I'm trying to use text links to share blog posts onto social media platforms, but I'm having problems with setting the current page as a link

I'm adding the code to my post.html template and using

<perch:blog id="postURL" /> to make sure that the page link is for the current post - and so the whole link I am using would be:

<a href="https://www.facebook.com/sharer.php?u=<perch:blog id="postURL" />" target="_blank" title="Click to share">Share on Facebook</a>

However the link it returns is something like

https://www.facebook.com/sharer/sharer.php?u=%2Fnews%2Fpost.php%3Fs%3D2015-01-26-shockwaves-sent-through-retail-sector-earlier-this-year-by-quitting-global-search-firm

NB - When I use a hard coded link like

<a href="https://www.facebook.com/sharer.php?u=www.mydomain.com" target="_blank" title="Click to share">Share on Facebook</a>

There is no problem - can you point me in the right direction as I'm obviously doing something very wrong

Thanks in advance

Ben

Ben Read

Ben Read 0 points

  • 6 years ago

As usual - after pulling my hair out for an hour I have tripped over a solution

So for anyone else with the same issue, I had to hard code the domain in front of the <perch:blog id="postURL" />

it may not be the best way (and if it's really poor coding I'd be happy to be put right)

but what I ended up using was the following:

<a href="https://www.facebook.com/sharer.php?u=+https://www.domain.com/<perch:blog id="postURL" />" target="_blank" title="Click to share">Share on Facebook</a>

Is this possible to do without the blog app?

Thanks in advance

Ben Read said:

As usual - after pulling my hair out for an hour I have tripped over a solution

So for anyone else with the same issue, I had to hard code the domain in front of the <perch:blog id="postURL" />

it may not be the best way (and if it's really poor coding I'd be happy to be put right)

but what I ended up using was the following:

<a href="https://www.facebook.com/sharer.php?u=+https://www.domain.com/<perch:blog id="postURL" />" target="_blank" title="Click to share">Share on Facebook</a>