Forum
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
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
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