3

I have a drupal8 site that uses the Entity Embed Module, to place teasers of content in the textflow of articles.

Now a visitor comes to the article page (node/6) which contains several embeded node teasers ( node/123, node/124 ...).
The visitor wants to share node/123 directly form that article page (node/6).
Each of the embeded Nodes need to have their specific appearance on the social media channels, which is easy as each of those has their own single node page (in this case node/123) with the appropriate opengraph meta tags set.
But I do not want to direct the users from social media back to that single node page (node/123), but instead bring them to the article (node/6) where the piece of content was embeded / where it was shared from originally.

What would be the preferred way to achieve this?

My ideas so far:

  1. Manipulate the meta tags of the article (node/6) depending on some url argument? (I don't know how to achieve that server side, so the social bot gets the right meta tags).

  2. Adding an argument to the url of the single node page (node/123) that is shared, that contains the url of the article where the node was embedded and shared from,
    and trigger a redirect with js when the url contains that argument.

To make it clear: Lets say I have an article with the url /node/6 which contains an embeded teaser of url node/123. Then my shareing button on the embeded node would contain this url:

eg: http://example.com/node/123?originalySharedFrom=http://example.com/node/6

var redirect_to_url = url.searchParams.get("originalySharedFrom");
if (redirect_to_url){
  window.location.replace(redirect_to_url);
}

would be the second approach be supported by most social-networks?
I have the feeling that solucion 2 is not the most robust one ...

verfranzt
  • 56
  • 5

0 Answers0