Share blogs from hugo website hosted on AWS

Hi there,
I’m serving a static website on AWS (code is on S3 bucket and redirected to mydomain.com) with Hugo (version v0.69, extended). The site runs correctly, except when i try to share a blog (the theme used is Meghna).

The partial is as follows (sample with the LinkedIn part) :

{{ $url := printf "%s" .Permalink | absLangURL }}
<a class="resp-sharing-button__link" 
href="https://www.linkedin.com/shareArticle?mini=true&amp;title={{ .Title }}&amp;url={{ $url }}" 
target="_blank" rel="noopener" aria-label=""> ...</a>

My issue is : the blog post is at https://mydomain.com/blogs/the-blog, but when i want to share, the absLangURL is just /blogs/the-blog (i’m guessing it does not resolve the baseUrl). So i’ve got an error on each website i try to share (twitter/reddit/linkedin/facebook etc) due to a misconstuction of the url.
When i run locally on my machine, the absLangUrl is http://localhost:1313/blogs/the-blog. S3 seems to be the problem then.

Any tips on how to resolve this please ?
Thanks in advance ! :pray:

First of all, you need to encode the title and the URL if you want to use them IN an URL. That is done by urlize:

Then you can just add .Site.BaseURL for the URL to your setup:

{{ $url := printf "%s" (.Permalink | absLangURL) }}
<a class="resp-sharing-button__link" 
href="https://www.linkedin.com/shareArticle?mini=true&amp;title={{ .Title | urlize }}&amp;url={{ .SiteBaseURL | urlize }}{{ $url | urlize }}" 
target="_blank" rel="noopener" aria-label=""> ...</a>

This is untested but should do the trick. If you are using only one language then .Permalink should be enough (and the full URL). Leave the absLangUrl out then.