Facebook like a hash button

when I try to add FB Like Button to my site with url + hash ( example.com/#TEST ) and I try to click a similar button - it shares the link without a hash in the news feed (example.com).

when I try to configure the button with "% 23" instand "#" ( example.com/%23TEST ) - it counts each hash separately in the counter field.

Is there a way to put a similar button with a hash - and still read the URL without a hash?

Thanks!

+4
source share
2 answers

When you create Facebook as buttons, Facebook uses cURL (trust me people) to access your metadata url. Thus , if cURL sees different metadata , for each URL, you will get different LIKE buttons.

But this does not happen; as on the server side, Facebook sees the same URL for each dynamic link # . Since the part of the link before # is the same. JavaScript (or any behavior that can create a hash in the URL) is ignored, obviously, since its behavior is only a client affair.

The best way would be to create the button dynamically using JavaScript and change the url for each button for something friendly without a hash.

 abc.com/def#part1 abc.com/def#part2 // to abc.com/def/part1 abc.com/def/part2 

Only for curl script to see it as another url.

And when the user clicks on this link - abc.com/def/part1 - you need help on the server side to redirect part1 to the def route to view. Thus, in your router code, you only load up to the def route (imagine MVC), and then ask the controller to load the part1 , with JavaScript enabled, to add the hash of the URL #part1 .

+7
source

These hash tags are for client-side actions, not server-side actions. You cannot use them in your Like button.

+1
source

Source: https://habr.com/ru/post/1414786/


All Articles