-1

Facebook's share stuff is beyond confusing to me and I've had nothing but headaches poring over their docs, so I must come here to clear up a few things:

1) Is it possible to make a custom button that shares a custom URL (https://example.com instead of https://example.com/here with either a custom image or the one in the meta tags on that page? The whole image should be a link on Facebook just like normal.

2) If so, how?

3) Is this made more complicated in Meteor where the entire page is built via JavaScript? I have a SEO package for meta tags but that's it.

Yeats
  • 1,950
  • 3
  • 21
  • 43

1 Answers1

2

I personally avoid facebook's javascript lib and widgets although I don't think they are that bad to implement.

Facebook does support a non-javascript option for sharing a link to facebook. This is what I prefer to use.

Share to facebook without javascript

Share link looks like this:

https://www.facebook.com/sharer/sharer.php?u=[URL-TO-SHARE-GOES-HERE]

You would replace [URL-TO-SHARE-GOES-HERE] with the URL you want to share. Example:

https://www.facebook.com/sharer/sharer.php?u=https://example.com

On your page you would create a share button like this:

<a href="https://www.facebook.com/sharer/sharer.php?u=http://example.com" target="_blank">
    <img src="[facebook-share-button]" />
</a>

[facebook-share-button] should be a url to the "custom button" you want the user to click on.

URL-encode the url (http://example.com) before adding it as a parameter. Otherwise more complicated URLs may not get shared properly. You can encode the url on the server side in your Content Management System (CMS) before returning the html to the user, or you can do it with javascript (encodeURIComponent).

Which image shows up on facebook for the link?

This post answers in detail: How does Facebook Sharer select Images and other metadata when sharing my URL?

Basically you add specific meta tags to the <head> section of your pages. This allows you to specify the image(s) to display explicitly.

Community
  • 1
  • 1
mattpr
  • 966
  • 9
  • 9