CMS Development

Klaasie
Membre

URL shortening in HubL

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 Votes
3 Réponses
Klaasie
Membre

URL shortening in HubL

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 Votes
Anton
Expert reconnu | Partenaire solutions Diamond
Expert reconnu | Partenaire solutions Diamond

URL shortening in HubL

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

Anton Bujanowski Signature
dennisedson
Équipe de développement de HubSpot
Équipe de développement de HubSpot

URL shortening in HubL

@Anton how would you solve for this?