URL shortening in HubL

Klaasie
Member

Hi all,

We have the following situation.
We want to add LinkedIn, Facebook and Twitter share buttons to for instance a blog or a page. When a visitor is clicking on that share button, he/she can share that blog via social media. The thing is. When URLs are long with parameters, then LI, FB and Twitter will cut the URL in the preview/text editor and the wrong URL would be shared.

So, is it possible to make use of an URL shortener with code in HubL or do you have other suggestions?

0 Upvotes
3 Replies 3
dennisedson
Community Manager

@Anton how would you solve for this?

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
Anton
Key Advisor | Diamond Partner

Hi @Klaasie,
Never really encountered such problems with the default social network sharing links. Might be an "URL structure" issue instead of the length.

Could you please post your code?

Thanks

Best,
Anton




check
Did my post help answer your query? Help the Community by marking it as a solution



Klaasie
Member

Hi @Anton 

In a module I use the social share URLs like.

<a class="linkedin customer share" href="https://www.linkedin.com/shareArticle?mini=true&url={{ content.absolute_url }}?{{ request.query }}" title="Share via LinkedIn" target="_blank">

<a class="facebook customer share" href="https://www.facebook.com/sharer.php?u={{ content.absolute_url }}?{{ request.query }}" title="Share via Facebook" target="_blank">


But the URLs are in some cases to long and are trimmed by LinkedIn, Facebook...
So I am wondering if you can use code or other options to generate a shorter URL via some HubL code?

0 Upvotes